]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
ceph-facts: fix grafana group conversion
authorDimitri Savineau <dsavinea@redhat.com>
Mon, 7 Dec 2020 17:11:54 +0000 (12:11 -0500)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 10 Dec 2020 15:51:16 +0000 (16:51 +0100)
The conversion fact task was only executed when the grafana_server_group_name
variable was explicitly set in the user configuration. If an user was using
the default value then the conversion wasn't executed.

This also adds back the default grafana_server_group_name value in case user
was using the default value and to avoid undefined variable error.

Instead of hardcoding the "monitoring" group name then we can reuse the
monitoring_group_name variable.

There's no need to override the monitoring_group_name variable, it's either
using the default value or the one defined by the user.

Finally removing the delegate_to statement on the add_host task since it's
always executed on the ansible controller.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1903732
Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
roles/ceph-facts/tasks/convert_grafana_server_group_name.yml
roles/ceph-facts/tasks/main.yml

index 15a0c9687c1d1f8123aa51b53349d1d7dffbadec..6e8912e0421bf7910a367c4adf7a7e6ac19a3d57 100644 (file)
@@ -2,15 +2,8 @@
 - name: convert grafana-server group name if exist
   add_host:
     name: "{{ item }}"
-    groups: "monitoring"
+    groups: "{{ monitoring_group_name }}"
     ansible_host: "{{ hostvars[item]['ansible_host'] | default(omit) }}"
     ansible_port: "{{ hostvars[item]['ansible_port'] | default(omit) }}"
-  delegate_to: localhost
-  with_items: "{{ groups.get(grafana_server_group_name, []) }}"
-  when: groups.get(grafana_server_group_name, []) | length > 0
-  run_once: True
-
-- name: set_fact monitoring_group_name
-  set_fact:
-    monitoring_group_name: "{{ grafana_server_group_name | default(monitoring_group_name) }}"
+  with_items: "{{ groups.get((grafana_server_group_name|default('grafana-server')), []) }}"
   run_once: True
index ba6cb138ef3a509faeff289849d5aff5e61e9f2d..48395f8571f207ded7b798aa0b6bae22c4cb3676 100644 (file)
@@ -1,7 +1,7 @@
 ---
 - name: include_tasks convert_grafana_server_group_name.yml
   include_tasks: convert_grafana_server_group_name.yml
-  when: grafana_server_group_name is defined
+  when: groups.get((grafana_server_group_name|default('grafana-server')), []) | length > 0
 
 - name: include facts.yml
   include_tasks: facts.yml