2015-01-30 23:16:18 +08:00
|
|
|
---
|
2018-10-24 00:38:40 +08:00
|
|
|
- name: waiting for the monitor(s) to form the quorum...
|
|
|
|
command: "ceph --cluster {{ cluster }} -n mon. -k /var/lib/ceph/mon/{{ cluster }}-{{ ansible_hostname }}/keyring mon_status --format json"
|
|
|
|
register: ceph_health_raw
|
|
|
|
until: >
|
|
|
|
(ceph_health_raw.stdout | from_json)['state'] in ['leader', 'peon']
|
|
|
|
retries: "{{ handler_health_mon_check_retries }}"
|
|
|
|
delay: "{{ handler_health_mon_check_delay }}"
|
|
|
|
when:
|
|
|
|
- ceph_release_num[ceph_release] >= ceph_release_num.nautilus
|
|
|
|
|
|
|
|
- name: fetch ceph keys in nautilus and above
|
|
|
|
ceph_key:
|
|
|
|
state: fetch_initial_keys
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
when:
|
|
|
|
- ceph_release_num[ceph_release] >= ceph_release_num.nautilus
|
|
|
|
- cephx
|
|
|
|
|
2017-07-01 02:04:51 +08:00
|
|
|
- name: collect admin and bootstrap keys
|
|
|
|
command: ceph-create-keys --cluster {{ cluster }} -i {{ monitor_name }} -t 30
|
|
|
|
changed_when: false
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2017-07-01 02:04:51 +08:00
|
|
|
when:
|
2018-10-24 00:38:40 +08:00
|
|
|
- ceph_release_num[ceph_release] < ceph_release_num.nautilus
|
2017-07-01 02:04:51 +08:00
|
|
|
- cephx
|
2017-03-17 05:31:25 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
# NOTE (leseb): wait for mon discovery and quorum resolution
|
2016-05-09 15:12:01 +08:00
|
|
|
# the admin key is not instantaneously created so we have to wait a bit
|
2017-07-01 02:04:51 +08:00
|
|
|
# msg: is only supported as of Ansible 2.4.
|
2016-12-15 04:08:18 +08:00
|
|
|
- name: "wait for {{ cluster }}.client.admin.keyring exists"
|
2015-10-17 07:55:31 +08:00
|
|
|
wait_for:
|
2016-03-29 21:37:31 +08:00
|
|
|
path: /etc/ceph/{{ cluster }}.client.admin.keyring
|
2017-07-01 02:04:51 +08:00
|
|
|
timeout: 30
|
|
|
|
msg: "Timed out while waiting for keyring creation. Check network settings on mon nodes."
|
|
|
|
when:
|
2018-10-24 00:38:40 +08:00
|
|
|
- ceph_release_num[ceph_release] < ceph_release_num.nautilus
|
2017-07-01 02:04:51 +08:00
|
|
|
- cephx
|
|
|
|
- (ansible_version.major == 2 and ansible_version.minor >= 4) or
|
|
|
|
ansible_version.major > 2
|
|
|
|
|
|
|
|
- name: "wait for {{ cluster }}.client.admin.keyring exists"
|
|
|
|
wait_for:
|
|
|
|
path: /etc/ceph/{{ cluster }}.client.admin.keyring
|
|
|
|
timeout: 30
|
|
|
|
when:
|
2018-10-24 00:38:40 +08:00
|
|
|
- ceph_release_num[ceph_release] < ceph_release_num.nautilus
|
2017-07-01 02:04:51 +08:00
|
|
|
- cephx
|
|
|
|
- ansible_version.major == 2 and ansible_version.minor < 4
|
2015-01-30 23:16:18 +08:00
|
|
|
|
2017-03-16 17:17:08 +08:00
|
|
|
- name: create ceph mgr keyring(s) when mon is not containerized
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "mgr.{{ hostvars[item]['ansible_hostname'] }}"
|
|
|
|
state: present
|
|
|
|
caps:
|
|
|
|
mon: allow profile mgr
|
|
|
|
osd: allow *
|
|
|
|
mds: allow *
|
|
|
|
cluster: "{{ cluster }}"
|
2018-07-31 07:24:21 +08:00
|
|
|
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
|
2017-03-16 17:17:08 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
|
|
|
- groups.get(mgr_group_name, []) | length > 0
|
|
|
|
- inventory_hostname == groups[mon_group_name]|last
|
2017-04-11 20:20:11 +08:00
|
|
|
with_items: "{{ groups.get(mgr_group_name, []) }}"
|
2016-01-22 03:54:41 +08:00
|
|
|
|
2018-04-04 22:22:36 +08:00
|
|
|
# once this gets backported github.com/ceph/ceph/pull/20983
|
|
|
|
# we will be able to remove these 2 tasks below
|
2015-07-24 02:01:43 +08:00
|
|
|
- name: find ceph keys
|
2015-01-30 23:16:18 +08:00
|
|
|
shell: ls -1 /etc/ceph/*.keyring
|
2015-06-26 06:26:03 +08:00
|
|
|
changed_when: false
|
2015-01-30 23:16:18 +08:00
|
|
|
register: ceph_keys
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
2015-01-30 23:16:18 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
- name: set keys permissions
|
2015-10-17 07:55:31 +08:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
2017-01-20 17:14:35 +08:00
|
|
|
owner: "ceph"
|
|
|
|
group: "ceph"
|
2018-06-25 21:12:56 +08:00
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
2015-03-23 22:08:58 +08:00
|
|
|
with_items:
|
2016-12-14 08:48:14 +08:00
|
|
|
- "{{ ceph_keys.get('stdout_lines') | default([]) }}"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
2015-03-23 22:08:58 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
- name: copy keys to the ansible server
|
2015-10-17 07:55:31 +08:00
|
|
|
fetch:
|
|
|
|
src: "{{ item }}"
|
|
|
|
dest: "{{ fetch_directory }}/{{ fsid }}/{{ item }}"
|
|
|
|
flat: yes
|
2015-01-30 23:16:18 +08:00
|
|
|
with_items:
|
2016-12-14 08:48:14 +08:00
|
|
|
- "{{ ceph_keys.get('stdout_lines') | default([]) }}"
|
2016-03-29 21:37:31 +08:00
|
|
|
- /var/lib/ceph/bootstrap-osd/{{ cluster }}.keyring
|
|
|
|
- /var/lib/ceph/bootstrap-rgw/{{ cluster }}.keyring
|
|
|
|
- /var/lib/ceph/bootstrap-mds/{{ cluster }}.keyring
|
2018-11-06 00:14:31 +08:00
|
|
|
- /var/lib/ceph/bootstrap-rbd/{{ cluster }}.keyring
|
|
|
|
- /var/lib/ceph/bootstrap-rbd-mirror/{{ cluster }}.keyring
|
2017-03-16 17:17:08 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
2017-09-15 06:48:53 +08:00
|
|
|
- inventory_hostname == groups[mon_group_name] | last
|