2018-04-11 23:15:29 +08:00
|
|
|
---
|
|
|
|
- name: create mgr directory
|
|
|
|
file:
|
|
|
|
path: /var/lib/ceph/mgr/{{ cluster }}-{{ ansible_hostname }}
|
|
|
|
state: directory
|
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
2020-01-21 22:30:16 +08:00
|
|
|
mode: "{{ ceph_directories_mode }}"
|
2018-04-11 23:15:29 +08:00
|
|
|
|
2018-12-03 18:15:30 +08:00
|
|
|
- name: fetch ceph mgr keyring
|
|
|
|
ceph_key:
|
|
|
|
name: "mgr.{{ ansible_hostname }}"
|
|
|
|
state: present
|
|
|
|
caps:
|
|
|
|
mon: allow profile mgr
|
|
|
|
osd: allow *
|
|
|
|
mds: allow *
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
|
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
mode: "0400"
|
|
|
|
dest: "/var/lib/ceph/mgr/{{ cluster }}-{{ ansible_hostname }}/keyring"
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
2019-04-01 23:46:15 +08:00
|
|
|
when: groups.get(mgr_group_name, []) | length == 0 # the key is present already since one of the mons created it in "create ceph mgr keyring(s)"
|
2018-12-03 18:15:30 +08:00
|
|
|
|
2019-05-02 20:48:00 +08:00
|
|
|
- name: create and copy keyrings
|
|
|
|
when: groups.get(mgr_group_name, []) | length > 0
|
|
|
|
block:
|
|
|
|
- name: create ceph mgr keyring(s) on a mon node
|
|
|
|
ceph_key:
|
|
|
|
name: "mgr.{{ hostvars[item]['ansible_hostname'] }}"
|
|
|
|
state: present
|
|
|
|
caps:
|
|
|
|
mon: allow profile mgr
|
|
|
|
osd: allow *
|
|
|
|
mds: allow *
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
|
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
mode: "0400"
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
with_items: "{{ groups.get(mgr_group_name, []) }}"
|
|
|
|
run_once: True
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
|
|
|
|
2019-09-23 19:30:05 +08:00
|
|
|
- name: set_fact _mgr_keys
|
|
|
|
set_fact:
|
2019-10-15 23:02:18 +08:00
|
|
|
_mgr_keys:
|
|
|
|
- { 'name': 'client.admin', 'path': "/etc/ceph/{{ cluster }}.client.admin.keyring", 'copy_key': copy_admin_key }
|
|
|
|
- { 'name': "mgr.{{ ansible_hostname }}", 'path': "/var/lib/ceph/mgr/{{ cluster }}-{{ ansible_hostname }}/keyring", 'copy_key': true }
|
2019-05-02 20:48:00 +08:00
|
|
|
|
2019-09-23 19:30:05 +08:00
|
|
|
- name: get keys from monitors
|
2020-01-15 21:39:16 +08:00
|
|
|
command: "{{ _container_exec_cmd | default('') }} ceph --cluster {{ cluster }} auth get {{ item.name }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
register: _mgr_keys
|
|
|
|
with_items: "{{ _mgr_keys }}"
|
2020-01-17 02:23:58 +08:00
|
|
|
delegate_to: "{{ groups[mon_group_name][0] if running_mon is undefined else running_mon }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
when:
|
|
|
|
- cephx | bool
|
|
|
|
- item.copy_key | bool
|
|
|
|
|
|
|
|
- name: copy ceph key(s) if needed
|
2019-05-02 20:48:00 +08:00
|
|
|
copy:
|
2019-09-23 19:30:05 +08:00
|
|
|
dest: "{{ item.item.path }}"
|
|
|
|
content: "{{ item.stdout + '\n' }}"
|
2019-05-02 20:48:00 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
with_items: "{{ _mgr_keys.results }}"
|
|
|
|
when:
|
|
|
|
- cephx | bool
|
|
|
|
- item.item.copy_key | bool
|
2018-04-11 23:15:29 +08:00
|
|
|
|
|
|
|
- name: set mgr key permissions
|
|
|
|
file:
|
|
|
|
path: /var/lib/ceph/mgr/{{ cluster }}-{{ ansible_hostname }}/keyring
|
|
|
|
owner: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment else 'ceph' }}"
|
2018-06-25 21:12:56 +08:00
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
2019-05-22 16:02:42 +08:00
|
|
|
when: cephx | bool
|