mirror of https://github.com/ceph/ceph-ansible.git
mgr: use state: 'auto' in ceph_mgr_module call
so we can get rid of the complexity in the playbook Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>improve-ceph-mgr-module
parent
d8685aaef6
commit
972a0aad6b
|
@ -18,10 +18,12 @@ __metaclass__ = type
|
|||
from ansible.module_utils.basic import AnsibleModule
|
||||
try:
|
||||
from ansible.module_utils.ca_common import exit_module, \
|
||||
pre_generate_cmd, \
|
||||
generate_cmd, \
|
||||
is_containerized
|
||||
except ImportError:
|
||||
from module_utils.ca_common import exit_module, \
|
||||
pre_generate_cmd, \
|
||||
generate_cmd, \
|
||||
is_containerized
|
||||
import datetime
|
||||
|
@ -114,8 +116,8 @@ def get_mgr_initial_modules(module,
|
|||
run_dir = get_run_dir(module, cluster, container_image)
|
||||
# /var/run/ceph/ceph-mon.mon0.asok
|
||||
socket_path = f"{run_dir}/{cluster}-mon.{node_name}.asok"
|
||||
cmd = ['ceph', '--admin-daemon', socket_path, 'config', 'get', 'mgr_initial_modules', '--format', 'json']
|
||||
|
||||
cmd = pre_generate_cmd('ceph', container_image)
|
||||
cmd.extend(['--admin-daemon', socket_path, 'config', 'get', 'mgr_initial_modules', '--format', 'json'])
|
||||
rc, out, err = module.run_command(cmd)
|
||||
if not rc and out:
|
||||
out = json.loads(out)
|
||||
|
|
|
@ -11,41 +11,12 @@
|
|||
- (mgr_dump.stdout | from_json).available | bool
|
||||
when: not ansible_check_mode
|
||||
|
||||
- name: get enabled modules from ceph-mgr
|
||||
command: "{{ hostvars[groups[mon_group_name][0]]['container_exec_cmd'] | default('') }} ceph --cluster {{ cluster }} --format json mgr module ls"
|
||||
check_mode: no
|
||||
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)
|
||||
set_fact:
|
||||
_ceph_mgr_modules: "{{ _ceph_mgr_modules.get('stdout', '{}') | from_json }}"
|
||||
|
||||
- name: set _disabled_ceph_mgr_modules fact
|
||||
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 }}"
|
||||
name: "{{ ceph_mgr_modules }}"
|
||||
cluster: "{{ cluster }}"
|
||||
state: enable
|
||||
state: auto
|
||||
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 == [])
|
||||
|
|
Loading…
Reference in New Issue