part_start
分割起點預設是 0%
碟碟最前端,另一參數 part_end
分割終點預設是 100%
硬碟最後端。
[deyu1@kvm19 ansible]$ ansible-doc parted | grep LVM -A6 - name: Create a new primary partition for LVM community.general.parted: device: /dev/sdb number: 2 flags: [ lvm ] state: present part_start: 1GiB
[deyu1@kvm19 ansible]$ ansible balancers -m shell -a "lsblk" kvm15 | CHANGED | rc=0 >> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS vda 252:0 0 6G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 400M 0 part /boot └─vda3 252:3 0 3.4G 0 part ├─vg_kvm15-root 253:0 0 3.3G 0 lvm / └─vg_kvm15-swap 253:1 0 96M 0 lvm [SWAP]
[deyu1@kvm19 ansible]$ vim partvg.yml [deyu1@kvm19 ansible]$ cat partvg.yml --- - hosts: balancers tasks: - name: Create a new primary partition for LVM community.general.parted: device: /dev/vda number: 4 flags: [ lvm ] state: present part_start: 3GiB
[deyu1@kvm19 ansible]$ ansible-playbook partvg.yml PLAY [balancers] **************************************************************** TASK [Gathering Facts] ********************************************************** ok: [kvm15] TASK [Create a new primary partition for LVM] *********************************** fatal: [kvm15]: FAILED! => {"changed": false, "err": "Error: You requested a partition from 3145728kiB to 6291456kiB (sectors 6291456..12582911).\nThe closest location we can manage is 3995648kiB to 6291456kiB (sectors 7991296..12582911).\n ", "msg": "Error while running parted script: /usr/sbin/parted -s -m -a optimal /dev/vda -- unit KiB mkpart primary 3GiB 100%", "out": "", "rc": 1} PLAY RECAP ********************************************************************** kvm15 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
part_start
為 3995648kiB,
[deyu1@kvm19 ansible]$ vim partvg.yml [deyu1@kvm19 ansible]$ grep part_start partvg.yml part_start: 3995648kiB ##3GiB
part_start
的大小單位不能用小寫。
[deyu1@kvm19 ansible]$ ansible-playbook partvg.yml PLAY [balancers] **************************************************************** TASK [Gathering Facts] ********************************************************** ok: [kvm15] TASK [Create a new primary partition for LVM] *********************************** fatal: [kvm11]: FAILED! => {"changed": false, "err": [3995648.0, "kiB"], "msg": "The argument 'part_start' doesn't respect required format.The size unit is case sensitive."} PLAY RECAP ********************************************************************** kvm15 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
part_start
為 3995648KiB,
KiB,K 要大寫。
[deyu1@kvm19 ansible]$ vim partvg.yml [deyu1@kvm19 ansible]$ grep part_start partvg.yml part_start: 3995648KiB ##3GiB
[deyu1@kvm19 ansible]$ ansible-playbook partvg.yml PLAY [balancers] **************************************************************** TASK [Gathering Facts] ********************************************************** ok: [kvm15] TASK [Create a new primary partition for LVM] *********************************** 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 "lsblk" kvm15 | CHANGED | rc=0 >> NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS vda 252:0 0 6G 0 disk ├─vda1 252:1 0 1M 0 part ├─vda2 252:2 0 400M 0 part /boot ├─vda3 252:3 0 3.4G 0 part │ ├─vg_kvm15-root 253:0 0 3.3G 0 lvm / │ └─vg_kvm15-swap 253:1 0 96M 0 lvm [SWAP] └─vda4 252:4 0 2.2G 0 part