Merge pull request #1 from Tcharl/id2

avoid reexecution of xfs creation
This commit is contained in:
Charlie Mordant
2020-04-15 19:01:39 +02:00
committed by GitHub
2 changed files with 48 additions and 25 deletions
+42 -19
View File
@@ -1,4 +1,20 @@
---
- name: manage_lvm | unmounting filesystem(s)
mount:
path: "{{ lv.mntp }}"
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
fstype: "{{ lv.filesystem | default(omit) }}"
state: "absent"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when: >
(lv is defined and
lv != 'None') and
(lv.create is defined and
not lv.create and
lv.filesystem != "swap")
- name: manage_lvm | creating new filesystem on new LVM logical volume(s)
filesystem:
@@ -25,6 +41,31 @@
)
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- name: lvm | check already converted
# at least xfs is executed twice if the partition has changed in the meantime
# then it tries to recreate the fs on the mounted fs which indeed fails...
shell: "xfs_info /dev/{{ vg.vgname }}/{{ lv.lvname }} | grep -c 'ftype=1'"
become: yes
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
register: mountedxfs
ignore_errors: True
changed_when: no
when: >
(
(lv is defined and item.1 != 'None') and
(
lv.filesystem is defined and
lv.filesystem == "xfs"
)
and
(
lv.create is defined and
lv.create
)
)
- name: manage_lvm | creating new xfs filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ lv.filesystem }}"
@@ -35,6 +76,7 @@
become: true
when: >
(
mountedxfs is failed and
(vg.create is defined and
vg.create) and
(lv is defined and
@@ -46,24 +88,6 @@
lv.filesystem == 'xfs'
)
)
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- name: manage_lvm | unmounting filesystem(s)
mount:
path: "{{ lv.mntp }}"
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
fstype: "{{ lv.filesystem | default(omit) }}"
state: "absent"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when: >
(lv is defined and
lv != 'None') and
(lv.create is defined and
not lv.create and
lv.filesystem != "swap")
- name: "debug mount"
loop: "{{ vg.lvnames }}"
@@ -71,7 +95,6 @@
loop_control:
loop_var: lv
- name: manage_lvm | mounting new filesystem(s)
mount:
path: "{{ lv.mntp }}"
+6 -6
View File
@@ -16,17 +16,17 @@
- name: manage_lvm | Removing LVM logical volume(s)
lvol:
vg: "{{ item.vgname }}"
lv: "{{ item.0.lvname }}"
vg: "{{ item.0.vgname }}"
lv: "{{ item.1.lvname }}"
state: "absent"
force: yes
become: true
loop: "{{ lvm_groups|subelements('lvnames') }}"
when: >
(item.0 is defined and
item.0 != 'None') and
(item.0.create is defined and
not item.0.create)
(item.1 is defined and
item.1 != 'None') and
(item.1.create is defined and
not item.1.create)
- name: manage_lvm | Removing LVM volume group(s)
lvg: