homeserver/roles/mrlesmithjr.ansible-manage-lvm/tasks/create_fs.yml

98 lines
2.5 KiB
YAML
Raw Normal View History

---
# unable to resize xfs: looks like we've to reference the mountpoint instead of the device
- name: create_fs | 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
register: mountedxfs
ignore_errors: true
changed_when: false
when:
- lv is defined and lv != 'None'
- lv.filesystem is defined
- lv.filesystem == "xfs"
- lv.create is defined
- lv.create|bool
- name: create_fs | unmounting filesystem(s)
mount:
path: "{{ lv.mntp }}"
src: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
fstype: "{{ lv.filesystem | default(omit) }}"
state: absent
become: true
when:
- lv is defined
- lv != 'None'
- lv.create is defined
- not lv.create|bool
- lv.filesystem != "swap"
- name: create_fs | creating new filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
resizefs: yes
become: true
when:
- vg.create is defined
- vg.create|bool
- lv is defined
- lv != 'None'
- lv.create is defined
- lv.create|bool
- lv.filesystem is defined
- lv.filesystem != 'None'
- lv.filesystem != 'swap'
- lv.filesystem != 'xfs'
- name: create_fs | creating new xfs filesystem on new LVM logical volume(s)
filesystem:
fstype: "{{ lv.filesystem }}"
dev: "/dev/{{ vg.vgname }}/{{ lv.lvname }}"
become: true
when:
- mountedxfs is failed
- vg.create is defined
- vg.create|bool
- lv is defined
- lv != 'None'
- lv.create is defined
- lv.create|bool
- lv.filesystem is defined
- lv.filesystem == 'xfs'
- name: create_fs | 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
when:
- vg.create is defined
- vg.create|bool
- lv is defined
- lv != 'None'
- lv.create is defined
- lv.create|bool
- lv.mount is defined
- lv.mount|bool
- name: create_fs | resizing xfs filesystem on new LVM logical volume(s)
command: "xfs_growfs {{ lv.mntp }}"
become: true
when:
- vg.create is defined
- vg.create|bool
- lv is defined
- lv != 'None'
- lv.create is defined
- lv.create|bool
- lv.filesystem is defined
- lv.filesystem == 'xfs'
- lvchanged.changed