]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
mgr: little refact
authorSébastien Han <seb@redhat.com>
Thu, 6 Dec 2018 12:58:37 +0000 (13:58 +0100)
committermergify[bot] <mergify[bot]@users.noreply.github.com>
Thu, 6 Dec 2018 14:55:56 +0000 (14:55 +0000)
This commit removes the default module, so ceph-ansible does not enable
any manager module.
To enable a module you need to set a value to 'ceph_mgr_modules', you
can pass a list of modules like this:

ceph_mgr_modules:
  - status
  - dashboard

Signed-off-by: Sébastien Han <seb@redhat.com>
group_vars/mgrs.yml.sample
roles/ceph-mgr/defaults/main.yml
roles/ceph-mgr/tasks/main.yml
roles/ceph-mgr/tasks/mgr_modules.yml [new file with mode: 0644]

index 58fd10848eef1d463559b6ca5152a2028ef1d9c2..1a85a38fdcb01497fa7821d243ccdc4911a6ab21 100644 (file)
@@ -20,8 +20,9 @@ dummy:
 ###########
 # MODULES #
 ###########
-# Ceph mgr modules to enable, current modules available are: status,dashboard,localpool,restful,zabbix,prometheus,influx
-#ceph_mgr_modules: [status]
+# Ceph mgr modules to enable, to view the list of available mpdules see: http://docs.ceph.com/docs/CEPH_VERSION/mgr/
+# and replace CEPH_VERSION with your current Ceph version, e,g: 'mimic'
+#ceph_mgr_modules: []
 
 
 ##########
index 6dfae8576065e6a0abeb0419665a26e568384bdd..db8ee45bc26d52b669e48e82a27947c69930c33e 100644 (file)
@@ -12,8 +12,9 @@ copy_admin_key: false
 ###########
 # MODULES #
 ###########
-# Ceph mgr modules to enable, current modules available are: status,dashboard,localpool,restful,zabbix,prometheus,influx
-ceph_mgr_modules: [status]
+# Ceph mgr modules to enable, to view the list of available mpdules see: http://docs.ceph.com/docs/CEPH_VERSION/mgr/
+# and replace CEPH_VERSION with your current Ceph version, e,g: 'mimic'
+ceph_mgr_modules: []
 
 
 ##########
index ff1ac2ea65e3255af949e36d7ecc87fbae01da0c..11f1e8230019f13428ba57e1718c3832c4543c40 100644 (file)
   include_tasks: pre_requisite.yml
   when: not containerized_deployment
 
-- name: inclide start_mgr.yml
+- name: include start_mgr.yml
   include_tasks: start_mgr.yml
 
-- name: get enabled modules from ceph-mgr
-  command: "{{ docker_exec_cmd_mgr | default('') }} ceph --cluster {{ cluster }} --format json mgr module ls"
-  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
-  command: "{{ docker_exec_cmd_mgr | default('') }} ceph --cluster {{ cluster }} mgr module disable {{ item }}"
-  # When ceph release is jewel, ceph-mgr role is skipped. It means, the enabled_ceph_mgr_modules doesn't contain 'stdout' attribute.
-  # Therefore, we need to get a default value which can be used up by from_json filter.
-  with_items: "{{ _ceph_mgr_modules.get('enabled_modules', []) }}"
-  delegate_to: "{{ groups[mon_group_name][0] }}"
-  when:
-    - item not in ceph_mgr_modules
-    - not _ceph_mgr_modules.get('skipped')
-
-- name: add modules to ceph-mgr
-  command: "{{ docker_exec_cmd_mgr | default('') }} ceph --cluster {{ cluster }} mgr module enable {{ item }}"
-  with_items: "{{ ceph_mgr_modules }}"
-  delegate_to: "{{ groups[mon_group_name][0] }}"
-  when:
-    - (item in _disabled_ceph_mgr_modules or _disabled_ceph_mgr_modules == [])
\ No newline at end of file
+- name: include mgr_modules.yml
+  include_tasks: mgr_modules.yml
+  when: ceph_mgr_modules|length > 0
\ No newline at end of file
diff --git a/roles/ceph-mgr/tasks/mgr_modules.yml b/roles/ceph-mgr/tasks/mgr_modules.yml
new file mode 100644 (file)
index 0000000..2cb68fe
--- /dev/null
@@ -0,0 +1,28 @@
+---
+- name: get enabled modules from ceph-mgr
+  command: "{{ docker_exec_cmd_mgr | default('') }} ceph --cluster {{ cluster }} --format json mgr module ls"
+  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
+  command: "{{ docker_exec_cmd_mgr | default('') }} ceph --cluster {{ cluster }} mgr module disable {{ item }}"
+  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
+  command: "{{ docker_exec_cmd_mgr | default('') }} ceph --cluster {{ cluster }} mgr module enable {{ item }}"
+  with_items: "{{ ceph_mgr_modules }}"
+  delegate_to: "{{ groups[mon_group_name][0] }}"
+  when:
+    - (item in _disabled_ceph_mgr_modules or _disabled_ceph_mgr_modules == [])
\ No newline at end of file