]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
mgr: use state: 'auto' in ceph_mgr_module call improve-ceph-mgr-module 7396/head
authorGuillaume Abrioux <gabrioux@ibm.com>
Tue, 7 Mar 2023 23:00:34 +0000 (00:00 +0100)
committerGuillaume Abrioux <gabrioux@ibm.com>
Thu, 4 May 2023 12:30:07 +0000 (14:30 +0200)
so we can get rid of the complexity in the playbook

Signed-off-by: Guillaume Abrioux <gabrioux@ibm.com>
library/ceph_mgr_module.py
roles/ceph-mgr/tasks/mgr_modules.yml

index c896c9faaacf2c5c52175b96bc695239df9ba5d0..638e7811dc1b1fee4280fe4f2ef643b94df78ca4 100644 (file)
@@ -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)
index 0f1c542830a503382ba95353937d6f7d94fbe647..7a7c7fdc8d19ad2759ea8ee6e98ad6ff258c3d3f 100644 (file)
     - (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 == [])