2016-12-16 23:24:48 +08:00
|
|
|
---
|
2018-11-01 19:47:17 +08:00
|
|
|
- name: check if /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring already exists
|
2016-12-16 23:24:48 +08:00
|
|
|
stat:
|
2018-11-01 19:47:17 +08:00
|
|
|
path: /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring
|
2016-12-16 23:24:48 +08:00
|
|
|
register: initial_mon_keyring
|
|
|
|
|
2018-11-01 19:47:17 +08:00
|
|
|
- name: fail if /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring doesn't exist
|
2016-12-16 23:24:48 +08:00
|
|
|
fail:
|
2018-11-01 19:47:17 +08:00
|
|
|
msg: "/var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring not found"
|
2016-12-16 23:24:48 +08:00
|
|
|
when:
|
|
|
|
- not initial_mon_keyring.stat.exists
|
|
|
|
|
|
|
|
- name: get existing initial mon keyring if it already exists but not monitor_keyring.conf in {{ fetch_directory }}
|
|
|
|
shell: |
|
2018-11-01 19:47:17 +08:00
|
|
|
grep key /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring | sed 's/^.*= //'
|
2016-12-16 23:24:48 +08:00
|
|
|
register: monitor_keyring
|
|
|
|
when:
|
|
|
|
- not monitor_keyring_conf.stat.exists
|
|
|
|
|
|
|
|
- name: test existing initial mon keyring
|
2018-11-01 19:47:17 +08:00
|
|
|
command: ceph --connect-timeout 3 --cluster {{ cluster }} --keyring /var/lib/ceph/mon/{{ cluster }}-{{ monitor_name }}/keyring -n mon. fsid
|
2018-10-30 22:51:32 +08:00
|
|
|
changed_when: false
|
2016-12-16 23:24:48 +08:00
|
|
|
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."
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- test_initial_monitor_keyring.rc != 0
|
2016-12-16 23:24:48 +08:00
|
|
|
|
|
|
|
- name: write initial mon keyring in {{ fetch_directory }}/monitor_keyring.conf if it doesn't exist
|
2018-11-01 19:50:31 +08:00
|
|
|
shell: "echo {{ monitor_keyring.stdout }} | tee {{ fetch_directory }}/monitor_keyring.conf"
|
|
|
|
delegate_to: localhost
|
2016-12-16 23:24:48 +08:00
|
|
|
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 }}
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- test_initial_monitor_keyring.rc == 0
|