2015-01-30 23:16:18 +08:00
|
|
|
---
|
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:
|
|
|
|
- cephx
|
2017-10-13 00:27:36 +08:00
|
|
|
- ceph_release_num[ceph_release] >= ceph_release_num.luminous
|
2017-07-01 02:04:51 +08:00
|
|
|
|
2017-03-17 05:31:25 +08:00
|
|
|
- name: collect admin and bootstrap keys
|
2017-01-17 20:13:43 +08:00
|
|
|
command: ceph-create-keys --cluster {{ cluster }} -i {{ monitor_name }}
|
|
|
|
changed_when: false
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2017-01-17 20:13:43 +08:00
|
|
|
when:
|
|
|
|
- cephx
|
2017-10-13 00:27:36 +08:00
|
|
|
- ceph_release_num[ceph_release] < ceph_release_num.luminous
|
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:
|
|
|
|
- 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:
|
|
|
|
- cephx
|
|
|
|
- ansible_version.major == 2 and ansible_version.minor < 4
|
2015-01-30 23:16:18 +08:00
|
|
|
|
2016-12-16 18:42:17 +08:00
|
|
|
- name: test if initial mon keyring is in mon kv store
|
|
|
|
command: ceph --cluster {{ cluster }} config-key get initial_mon_keyring
|
|
|
|
changed_when: false
|
2017-01-03 20:48:59 +08:00
|
|
|
ignore_errors: true
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2016-12-16 18:42:17 +08:00
|
|
|
run_once: true
|
2017-05-05 16:44:58 +08:00
|
|
|
failed_when: false
|
2016-12-16 18:42:17 +08:00
|
|
|
register: is_initial_mon_keyring_in_kv
|
|
|
|
|
|
|
|
- name: put initial mon keyring in mon kv store
|
|
|
|
command: ceph --cluster {{ cluster }} config-key put initial_mon_keyring {{ monitor_keyring.stdout }}
|
|
|
|
changed_when: false
|
2017-10-25 22:53:34 +08:00
|
|
|
check_mode: no
|
2016-12-16 18:42:17 +08:00
|
|
|
run_once: true
|
2017-01-02 18:16:03 +08:00
|
|
|
when:
|
|
|
|
- is_initial_mon_keyring_in_kv.rc != 0
|
|
|
|
- cephx
|
2016-12-16 18:42:17 +08:00
|
|
|
|
2016-01-22 03:54:41 +08:00
|
|
|
- name: create ceph rest api keyring when mon is not containerized
|
2018-04-04 22:22:36 +08:00
|
|
|
ceph_key:
|
|
|
|
name: client.restapi
|
|
|
|
state: present
|
|
|
|
caps:
|
|
|
|
mon: allow *
|
|
|
|
osd: allow *
|
|
|
|
cluster: "{{ cluster }}"
|
2015-06-26 06:26:03 +08:00
|
|
|
when:
|
2016-05-09 22:08:33 +08:00
|
|
|
- cephx
|
2017-03-16 17:17:08 +08:00
|
|
|
- groups.get(restapi_group_name, []) | length > 0
|
|
|
|
- inventory_hostname == groups[mon_group_name]|last
|
|
|
|
|
|
|
|
- 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 }}"
|
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-10-13 00:27:36 +08:00
|
|
|
- ceph_release_num[ceph_release] > ceph_release_num.jewel
|
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"
|
|
|
|
mode: "0600"
|
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
|
|
|
|
2017-09-15 06:48:53 +08:00
|
|
|
- name: set_fact bootstrap_rbd_keyring
|
2017-08-11 20:31:55 +08:00
|
|
|
set_fact:
|
|
|
|
bootstrap_rbd_keyring: "/var/lib/ceph/bootstrap-rbd/{{ cluster }}.keyring"
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
2017-10-13 00:27:36 +08:00
|
|
|
- ceph_release_num[ceph_release] >= ceph_release_num.luminous
|
2017-08-11 20:31:55 +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
|
2017-08-11 20:31:55 +08:00
|
|
|
- "{{ bootstrap_rbd_keyring | default([]) }}"
|
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
|
2015-01-30 23:16:18 +08:00
|
|
|
|
2015-05-16 00:27:41 +08:00
|
|
|
- name: drop in a motd script to report status when logging in
|
2015-10-17 07:55:31 +08:00
|
|
|
copy:
|
|
|
|
src: precise/92-ceph
|
|
|
|
dest: /etc/update-motd.d/92-ceph
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
2017-09-15 06:48:53 +08:00
|
|
|
when:
|
|
|
|
- ansible_distribution_release == 'precise'
|