Files
ansible-manage-lvm/tasks/create_fs.yml
Charlie Mordant 325c2d6240 install xfs
2020-04-23 19:25:09 +02:00

111 lines
2.6 KiB
YAML

---
- 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:
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
resizefs: yes
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when: >
(
(vg.create is defined and
vg.create) and
(lv is defined and
lv != 'None') and
(lv.create is defined and
lv.create) and
(
lv.filesystem is defined and
lv.filesystem != 'None' and
lv.filesystem != 'xfs'
)
)
# 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 {{ lv.mntp }} | 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 lv != '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 }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
become: true
when: >
(
mountedxfs is failed and
(vg.create is defined and
vg.create) and
(lv is defined and
lv != 'None') and
(lv.create is defined and
lv.create) and
(
lv.filesystem is defined and
lv.filesystem == 'xfs'
)
)
- name: manage_lvm | mounting new filesystem(s)
mount:
path: "{{ lv.mntp }}"
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
fstype: "{{ lv.filesystem }}"
state: "mounted"
opts: "{{ lv.mopts | default('defaults') }}"
become: true
loop: "{{ vg.lvnames }}"
loop_control:
loop_var: lv
when: >
((vg.create is defined and
vg.create) and
lv != 'None' and
(lv.create is defined and
lv.create) and
(lv.mount is defined and
lv.mount))