From 5457312e6232ffc8df0c4e47e9914ff7322049e4 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Mon, 20 May 2019 16:32:08 +0200 Subject: [PATCH] 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 --- site-container.yml.sample | 2 +- site.yml.sample | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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: