From cc046a757c4d6fe34e27100ec2ed7d477b540777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Mon, 11 Jun 2018 11:23:55 +0200 Subject: [PATCH] Do not fail on non existent ansible group When a role is defined but this role has a host count of 0, the ansible tasks to generate the openshift inventory for the service would fail with an undefined variable error. Setting the value for non existent groups to empty array should get us past the error. Change-Id: Ib42708c095d28827f5decdb885ceb4f2a67b3a8b --- extraconfig/services/openshift-master.yaml | 2 +- extraconfig/services/openshift-worker.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extraconfig/services/openshift-master.yaml b/extraconfig/services/openshift-master.yaml index 4f726c5fbd..2832b11aa1 100644 --- a/extraconfig/services/openshift-master.yaml +++ b/extraconfig/services/openshift-master.yaml @@ -97,7 +97,7 @@ outputs: template: | masters: hosts: - {% for host in groups['ROLENAME'] -%} + {% for host in groups['ROLENAME'] | default([]) -%} {{ hostvars.raw_get(host)['ansible_hostname'] }}: ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }} ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }} diff --git a/extraconfig/services/openshift-worker.yaml b/extraconfig/services/openshift-worker.yaml index 9482c984fb..761e4c7eff 100644 --- a/extraconfig/services/openshift-worker.yaml +++ b/extraconfig/services/openshift-worker.yaml @@ -77,7 +77,7 @@ outputs: template: | nodes: hosts: - {% for host in groups['ROLENAME'] -%} + {% for host in groups['ROLENAME'] | default([]) -%} {{ hostvars.raw_get(host)['ansible_hostname'] }}: ansible_user: {{ hostvars.raw_get(host)['ansible_user'] | default(hostvars.raw_get(host)['ansible_ssh_user']) | default('root') }} ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }}