Add pvresize option

You can now define the pvresize per vg.

To avoid a breaking change, the global option pvresize_to_max is set as default
This commit is contained in:
Gino Naumann 2024-01-16 12:50:12 +01:00
parent 3ac9669088
commit 91f8cfca5d
No known key found for this signature in database
GPG Key ID: B3C8FBBB996C39ED
2 changed files with 4 additions and 17 deletions

View File

@ -9,6 +9,8 @@ lvm_groups: []
# # defines if VG should exist or be removed
# # true or false
# create: true
# # defines if PV should be resized to max size
# pvresize: false
# lvnames:
# - lvname: swap_1
# # Define size of lvol
@ -86,8 +88,5 @@ ebsnvme_binary_helper_path: '/sbin/go-ebsnvme'
### nvme to scsi device name map script helper
ebsnvme_scrip_helper_path: '/usr/local/bin/ebsnvme-id'
### auto pvresize (waiting until ansible 2.10 or above as collections have new lvg with integrated pvresize)
### waiting for new module in collection set to true or run pvresize manually on remote systems
### https://docs.ansible.com/ansible/3/collections/community/general/lvg_module.html
###
### resize all pv's to max size
pvresize_to_max: false

View File

@ -4,24 +4,12 @@
vg: "{{ vg.vgname }}"
pvs: "{{ vg.disks | join(',') }}"
state: present
pvresize: "{{ vg.pvresize | default(pvresize_to_max) }}"
become: true
when:
- vg.create is defined
- vg.create|bool
### workaround: auto pvresize waiting for upgrade to new module supporting integrated pvresize
### ref: https://docs.ansible.com/ansible/3/collections/community/general/lvg_module.html
- name: create_vg | pvresize to max available free space
ansible.builtin.command: "pvresize {{ pv }}"
loop: "{{ vg.disks | default([]) }}"
loop_control:
loop_var: pv
changed_when: false
when:
- vg.create is defined
- vg.create|bool
- pvresize_to_max|bool
- name: manage_lvm | loop over logical volume group(s) to create logical volumes
ansible.builtin.include_tasks: create_lv.yml
loop: "{{ vg.lvnames | default([]) }}"