[deyu1@kvm19 ansible]$ ansible-doc lvg | grep ^EX -A6
EXAMPLES:
- name: Create a volume group on top of /dev/sda1 with physical extent size = 32MB
community.general.lvg:
vg: vg.services
pvs: /dev/sda1
pesize: 32
[deyu1@kvm19 ansible]$ vim partvg.yml
[deyu1@kvm19 ansible]$ cat partvg.yml
---
- hosts: dev
tasks:
- name: Create a new primary partition for LVM
community.general.parted:
device: /dev/vda
number: 4
flags: [ lvm ]
state: present
part_start: 3995648KiB ##3GiB
- name: Create a volume group on top of /dev/vda4
community.general.lvg:
vg: vg4
pvs: /dev/vda4
pesize: 8
[deyu1@kvm19 ansible]$ ansible-playbook partvg.yml PLAY [balancers] **************************************************************** TASK [Gathering Facts] ********************************************************** ok: [kvm15] TASK [Create a new primary partition for LVM] *********************************** ok: [kvm15] TASK [Create a volume group on top of /dev/vda4] ******************************** changed: [kvm15] PLAY RECAP ********************************************************************** kvm15 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
[deyu1@kvm19 ansible]$ ansible balancers -m shell -a "vgs" kvm15 | CHANGED | rc=0 >> VG #PV #LV #SN Attr VSize VFree vg4 1 0 0 wz--n- <2.19g <2.19g vg_kvm15 1 2 0 wz--n- 3.41g 0