From: Logan V Date: Fri, 16 Dec 2016 15:24:48 +0000 (-0600) Subject: Workaround for broken 'block' syntax X-Git-Tag: v2.2.10~61^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=824ba95571e4c136e324b2baf6e4e11922bfdfef;p=ceph-ansible.git Workaround for broken 'block' syntax The block syntax in ansible is broken on 2.1 so we work around the issue introduced in 471be5e by using a task file include. --- diff --git a/tasks/facts.yml b/tasks/facts.yml index 6d36fe58b..49a936ad3 100644 --- a/tasks/facts.yml +++ b/tasks/facts.yml @@ -39,46 +39,7 @@ register: monitor_keyring_conf run_once: true -- block: - - name: check if /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring already exists - stat: - path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring - register: initial_mon_keyring - - - name: fail if /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring doesn't exist - fail: - msg: "/var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring not found" - when: - - not initial_mon_keyring.stat.exists - - ceph_current_fsid.rc == 0 - - - name: get existing initial mon keyring if it already exists but not monitor_keyring.conf in {{ fetch_directory }} - shell: | - grep key /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring | sed 's/^.*= //' - register: monitor_keyring - when: - - not monitor_keyring_conf.stat.exists - - ceph_current_fsid.rc == 0 - - - name: test existing initial mon keyring - command: ceph --connect-timeout 3 --cluster {{ cluster }} --keyring /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring -n mon. fsid - register: test_initial_monitor_keyring - ignore_errors: true - - - name: fail if initial mon keyring found doesn't work - fail: - msg: "Initial mon keyring found doesn't work." - when: test_initial_monitor_keyring.rc != 0 - - - name: write initial mon keyring in {{ fetch_directory }}/monitor_keyring.conf if it doesn't exist - local_action: shell echo {{ monitor_keyring.stdout }} | tee {{ fetch_directory }}/monitor_keyring.conf - become: false - when: - - test_initial_monitor_keyring.rc == 0 - - - name: put initial mon keyring in mon kv store - command: ceph --cluster {{ cluster }} config-key put initial_mon_keyring {{ monitor_keyring.stdout }} - when: test_initial_monitor_keyring.rc == 0 +- include: facts_mon_fsid.yml run_once: true when: - not monitor_keyring_conf.stat.exists diff --git a/tasks/facts_mon_fsid.yml b/tasks/facts_mon_fsid.yml new file mode 100644 index 000000000..cafe13ae3 --- /dev/null +++ b/tasks/facts_mon_fsid.yml @@ -0,0 +1,40 @@ +--- +- name: check if /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring already exists + stat: + path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring + register: initial_mon_keyring + +- name: fail if /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring doesn't exist + fail: + msg: "/var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring not found" + when: + - not initial_mon_keyring.stat.exists + - ceph_current_fsid.rc == 0 + +- name: get existing initial mon keyring if it already exists but not monitor_keyring.conf in {{ fetch_directory }} + shell: | + grep key /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring | sed 's/^.*= //' + register: monitor_keyring + when: + - not monitor_keyring_conf.stat.exists + - ceph_current_fsid.rc == 0 + +- name: test existing initial mon keyring + command: ceph --connect-timeout 3 --cluster {{ cluster }} --keyring /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring -n mon. fsid + register: test_initial_monitor_keyring + ignore_errors: true + +- name: fail if initial mon keyring found doesn't work + fail: + msg: "Initial mon keyring found doesn't work." + when: test_initial_monitor_keyring.rc != 0 + +- name: write initial mon keyring in {{ fetch_directory }}/monitor_keyring.conf if it doesn't exist + local_action: shell echo {{ monitor_keyring.stdout }} | tee {{ fetch_directory }}/monitor_keyring.conf + become: false + when: + - test_initial_monitor_keyring.rc == 0 + +- name: put initial mon keyring in mon kv store + command: ceph --cluster {{ cluster }} config-key put initial_mon_keyring {{ monitor_keyring.stdout }} + when: test_initial_monitor_keyring.rc == 0