From: Guillaume Abrioux Date: Mon, 20 May 2019 14:32:08 +0000 (+0200) Subject: dashboard: add a last default value in grafana-server host section X-Git-Tag: v5.0.0alpha1~299 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5457312e6232ffc8df0c4e47e9914ff7322049e4;p=ceph-ansible.git dashboard: add a last default value in grafana-server host section If there is no mgrs and mons in the inventory, it will fail with the following error: ``` ERROR! The field 'hosts' has an invalid value, which includes an undefined variable. The error was: 'dict object' has no attribute 'mons' The error appears to be in '/home/guits/ceph-ansible/site-docker.yml.sample': line 539, column 3, but may be elsewhere in the file depending on the exact syntax problem. The offending line appears to be: - hosts: '{{ (groups["mgrs"] | default(groups["mons"]))[0] }}' ^ here We could be wrong, but this one looks like it might be an issue with missing quotes. Always quote template expression brackets when they start a value. For instance: with_items: - {{ foo }} Should be written as: with_items: - "{{ foo }}" ``` let's add an `omit` so it just display this message instead: ``` PLAY [[]] ******************* skipping: no hosts matched ``` Signed-off-by: Guillaume Abrioux --- diff --git a/site-container.yml.sample b/site-container.yml.sample index 6063108f1..53f7cb806 100644 --- a/site-container.yml.sample +++ b/site-container.yml.sample @@ -558,7 +558,7 @@ name: ceph-grafana when: dashboard_enabled -- hosts: '{{ (groups["mgrs"] | default(groups["mons"]))[0] }}' +- hosts: '{{ (groups["grafana-server"] | default(groups["mgrs"]) | default(groups["mons"]))[0] | default(omit) }}' become: true tasks: - block: diff --git a/site.yml.sample b/site.yml.sample index 8696959e0..d8726ecf5 100644 --- a/site.yml.sample +++ b/site.yml.sample @@ -487,7 +487,7 @@ name: ceph-grafana when: dashboard_enabled -- hosts: '{{ (groups["mgrs"] | default(groups["mons"]))[0] }}' +- hosts: '{{ (groups["grafana-server"] | default(groups["mgrs"]) | default(groups["mons"]))[0] | default(omit) }}' become: true tasks: - import_role: