2018-04-11 23:15:29 +08:00
|
|
|
---
|
|
|
|
- name: create mgr directory
|
|
|
|
file:
|
2021-03-03 22:43:50 +08:00
|
|
|
path: /var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}
|
2018-04-11 23:15:29 +08:00
|
|
|
state: directory
|
2020-09-26 00:15:02 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool 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:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "mgr.{{ ansible_facts['hostname'] }}"
|
2018-12-03 18:15:30 +08:00
|
|
|
caps:
|
|
|
|
mon: allow profile mgr
|
|
|
|
osd: allow *
|
|
|
|
mds: allow *
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
|
2020-09-26 00:15:02 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
2018-12-03 18:15:30 +08:00
|
|
|
mode: "0400"
|
2021-03-03 22:43:50 +08:00
|
|
|
dest: "/var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}/keyring"
|
2018-12-03 18:15:30 +08:00
|
|
|
environment:
|
2020-09-26 00:15:02 +08:00
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
2018-12-03 18:15:30 +08:00
|
|
|
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)"
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|
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:
|
2021-03-03 22:43:50 +08:00
|
|
|
name: "mgr.{{ hostvars[item]['ansible_facts']['hostname'] }}"
|
2019-05-02 20:48:00 +08:00
|
|
|
caps:
|
|
|
|
mon: allow profile mgr
|
|
|
|
osd: allow *
|
|
|
|
mds: allow *
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
secret: "{{ (mgr_secret != 'mgr_secret') | ternary(mgr_secret, omit) }}"
|
2020-09-26 00:15:02 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
2019-05-02 20:48:00 +08:00
|
|
|
mode: "0400"
|
|
|
|
environment:
|
2020-09-26 00:15:02 +08:00
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
2019-05-02 20:48:00 +08:00
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
|
|
|
with_items: "{{ groups.get(mgr_group_name, []) }}"
|
|
|
|
run_once: True
|
|
|
|
delegate_to: "{{ groups[mon_group_name][0] }}"
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|
2019-05-02 20:48:00 +08:00
|
|
|
|
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:
|
2023-03-03 22:15:16 +08:00
|
|
|
- { 'name': 'client.admin', 'path': "/etc/ceph/{{ cluster }}.client.admin.keyring", 'copy_key': "{{ copy_admin_key }}" }
|
2021-03-03 22:43:50 +08:00
|
|
|
- { 'name': "mgr.{{ ansible_facts['hostname'] }}", 'path': "/var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['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-10-24 03:19:53 +08:00
|
|
|
ceph_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
cluster: "{{ cluster }}"
|
|
|
|
output_format: plain
|
|
|
|
state: info
|
|
|
|
environment:
|
|
|
|
CEPH_CONTAINER_IMAGE: "{{ ceph_docker_registry + '/' + ceph_docker_image + ':' + ceph_docker_image_tag if containerized_deployment | bool else None }}"
|
|
|
|
CEPH_CONTAINER_BINARY: "{{ container_binary }}"
|
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
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
|
|
|
|
- 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' }}"
|
2020-09-26 00:15:02 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
2019-05-02 20:48:00 +08:00
|
|
|
mode: "{{ ceph_keyring_permissions }}"
|
2019-09-23 19:30:05 +08:00
|
|
|
with_items: "{{ _mgr_keys.results }}"
|
|
|
|
when:
|
|
|
|
- cephx | bool
|
2020-09-01 17:24:59 +08:00
|
|
|
- item is not skipped
|
2019-09-23 19:30:05 +08:00
|
|
|
- item.item.copy_key | bool
|
2021-08-09 20:57:33 +08:00
|
|
|
no_log: "{{ no_log_on_ceph_key_tasks }}"
|
2018-04-11 23:15:29 +08:00
|
|
|
|
|
|
|
- name: set mgr key permissions
|
|
|
|
file:
|
2021-03-03 22:43:50 +08:00
|
|
|
path: /var/lib/ceph/mgr/{{ cluster }}-{{ ansible_facts['hostname'] }}/keyring
|
2020-09-26 00:15:02 +08:00
|
|
|
owner: "{{ ceph_uid if containerized_deployment | bool else 'ceph' }}"
|
|
|
|
group: "{{ ceph_uid if containerized_deployment | bool 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
|
2021-07-16 03:38:07 +08:00
|
|
|
|
|
|
|
- name: append dashboard modules to ceph_mgr_modules
|
|
|
|
set_fact:
|
|
|
|
ceph_mgr_modules: "{{ ceph_mgr_modules | union(['dashboard', 'prometheus']) }}"
|
|
|
|
when: dashboard_enabled | bool
|