]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
dashboard: add a last default value in grafana-server host section
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 20 May 2019 14:32:08 +0000 (16:32 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Mon, 3 Jun 2019 11:36:38 +0000 (13:36 +0200)
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>
site-container.yml.sample
site.yml.sample

index 6063108f19cdab099cd2f57f1e686b37619fec5b..53f7cb8065bd03f84dc31cccfa1155bd02b55281 100644 (file)
           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:
index 8696959e0e33ec5eaacc8f01da801d8df187defe..d8726ecf5208110804698a8c3e60e77b7eaa519a 100644 (file)
             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: