Commit 6f90e7c9 by Joseph Mulloy

Make fs force creation explicit OPS-2205

Needed because behavior of Ansible force variable changed
https://github.com/ansible/ansible-modules-extras/pull/1493
parent 40d2b1cb
......@@ -13,3 +13,7 @@
volumes: []
UNMOUNT_DISKS: false
# WARNING! FORCE_REFORMAT_DISKS will cause your volumes to always be reformatted
# even if all the volume's attributes already match what you've defined in volumes[]
# Enable this flag at your own risk with an abundance of caution
FORCE_REFORMAT_DISKS: false
......@@ -26,6 +26,16 @@
when: "UNMOUNT_DISKS and (ansible_mounts | selectattr('device', 'equalto', item.device) | first | default({'fstype': None})).fstype != item.fstype"
with_items: "{{ volumes }}"
# If there are disks we want to be unmounting, but we can't because UNMOUNT_DISKS is false
# that is an errorable condition, since it will cause the format step to fail
- name: Check that we don't want to unmount disks to change fstype when UNMOUNT_DISKS is false
fail: msg="Found disks mounted with the wrong filesystem type, but can't unmount them. This role will need to be re-run with -e 'UNMOUNT_DISKS=True' if you believe that is safe."
when:
"not UNMOUNT_DISKS and
volumes | selectattr('device', 'equalto', item.device) | list | length != 0 and
(volumes | selectattr('device', 'equalto', item.device) | first).fstype != item.fstype"
with_items: "{{ ansible_mounts }}"
# Noop & reports "ok" if fstype is correct
# Errors if fstype is wrong and disk is mounted (hence above task)
- name: Create filesystem
......@@ -33,7 +43,7 @@
dev: "{{ item.device }}"
fstype: "{{ item.fstype }}"
# Necessary because AWS gives some ephemeral disks the wrong fstype by default
force: true
force: "{{ FORCE_REFORMAT_DISKS }}"
with_items: "{{ volumes }}"
# This can fail if one volume is mounted on a child directory as another volume
......@@ -57,7 +67,7 @@
# If there are disks we want to be unmounting, but we can't because UNMOUNT_DISKS is false
# that is an errorable condition, since it can easily allow us to double mount a disk.
- name: Check that we don't want to unmount disks when UNMOUNT_DISKS is false
- name: Check that we don't want to unmount disks to change mountpoint when UNMOUNT_DISKS is false
fail: msg="Found disks mounted in the wrong place, but can't unmount them. This role will need to be re-run with -e 'UNMOUNT_DISKS=True' if you believe that is safe."
when:
not UNMOUNT_DISKS and
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment