ceph-ansible/roles/ceph-mgr/tasks/mgr_modules.yml

52 lines
2.3 KiB
YAML

---
- name: Wait for all mgr to be up
ansible.builtin.command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} mgr dump -f json"
register: mgr_dump
retries: 30
delay: 5
delegate_to: "{{ groups[mon_group_name][0] }}"
changed_when: false
until:
- mgr_dump.rc == 0
- (mgr_dump.stdout | from_json).available | bool
when: not ansible_check_mode
- name: Get enabled modules from ceph-mgr
ansible.builtin.command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} --format json mgr module ls"
check_mode: false
changed_when: false
register: _ceph_mgr_modules
delegate_to: "{{ groups[mon_group_name][0] }}"
- name: Set _ceph_mgr_modules fact (convert _ceph_mgr_modules.stdout to a dict)
ansible.builtin.set_fact:
_ceph_mgr_modules: "{{ _ceph_mgr_modules.get('stdout', '{}') | from_json }}"
- name: Set _disabled_ceph_mgr_modules fact
ansible.builtin.set_fact:
_disabled_ceph_mgr_modules: "{% if _ceph_mgr_modules.disabled_modules | length == 0 %}[]{% elif _ceph_mgr_modules.disabled_modules[0] | type_debug != 'dict' %}{{ _ceph_mgr_modules['disabled_modules'] }}{% else %}{{ _ceph_mgr_modules['disabled_modules'] | map(attribute='name') | list }}{% endif %}"
- name: Disable ceph mgr enabled modules
ceph_mgr_module:
name: "{{ item }}"
cluster: "{{ cluster }}"
state: disable
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 }}"
with_items: "{{ _ceph_mgr_modules.get('enabled_modules', []) }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
when: item not in ceph_mgr_modules
- name: Add modules to ceph-mgr
ceph_mgr_module:
name: "{{ item }}"
cluster: "{{ cluster }}"
state: enable
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 }}"
with_items: "{{ ceph_mgr_modules }}"
delegate_to: "{{ groups[mon_group_name][0] }}"
when: (item in _disabled_ceph_mgr_modules or _disabled_ceph_mgr_modules == [])