From 220a4a1369a4bae13579c527e2eb9e9ef55debe1 Mon Sep 17 00:00:00 2001 From: Guillaume Abrioux Date: Wed, 29 Jun 2022 08:59:55 +0200 Subject: [PATCH] backup-and-restore: fix check on 'target_node' variable 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 (cherry picked from commit b18a1aa3cafa235dfa4f564d6574318ee539f961) --- infrastructure-playbooks/backup-and-restore-ceph-files.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/infrastructure-playbooks/backup-and-restore-ceph-files.yml b/infrastructure-playbooks/backup-and-restore-ceph-files.yml index a01d0e88a..2913310ce 100644 --- a/infrastructure-playbooks/backup-and-restore-ceph-files.yml +++ b/infrastructure-playbooks/backup-and-restore-ceph-files.yml @@ -28,7 +28,9 @@ msg: > "You must pass the node name: -e target_node=. 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: