diff --git a/tasks/create_fs.yml b/tasks/create_fs.yml index 037baa5..c068417 100644 --- a/tasks/create_fs.yml +++ b/tasks/create_fs.yml @@ -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 }}"