]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
backup-and-restore: fix check on 'target_node' variable
authorGuillaume Abrioux <gabrioux@redhat.com>
Wed, 29 Jun 2022 06:59:55 +0000 (08:59 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Wed, 29 Jun 2022 07:09:06 +0000 (09:09 +0200)
If the user doesn't pass a valid name (present in the inventory)
the playbook will fail like following:

```
fatal: [localhost -> {{ target_node }}]: FAILED! =>
  msg: |-
    The task includes an option with an undefined variable. The error was: "hostvars['10.70.46.40']" is undefined
```

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2051640
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit b18a1aa3cafa235dfa4f564d6574318ee539f961)

infrastructure-playbooks/backup-and-restore-ceph-files.yml

index a01d0e88abf063d3f4ea6604b8dab034d71e2a7e..2913310ceafff30c26d8df7059c9e1151305c342 100644 (file)
@@ -28,7 +28,9 @@
         msg: >
           "You must pass the node name: -e target_node=<inventory_name>.
           The name must match what is set in your inventory."
-      when: target_node is not defined
+      when:
+        - target_node is not defined
+          or target_node not in groups.get('all', [])
 
     - name: exit playbook, if user did not set the backup directory
       fail: