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 <gabrioux@redhat.com>
pull/4046/head
Guillaume Abrioux 2019-05-20 16:32:08 +02:00
parent 6e2e30db54
commit 5457312e62
2 changed files with 2 additions and 2 deletions

View File

@ -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:

View File

@ -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: