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
This commit is contained in:
parent
b95d1c18d8
commit
cc046a757c
@ -97,7 +97,7 @@ outputs:
|
|||||||
template: |
|
template: |
|
||||||
masters:
|
masters:
|
||||||
hosts:
|
hosts:
|
||||||
{% for host in groups['ROLENAME'] -%}
|
{% for host in groups['ROLENAME'] | default([]) -%}
|
||||||
{{ hostvars.raw_get(host)['ansible_hostname'] }}:
|
{{ 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_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) }}
|
ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }}
|
||||||
|
@ -77,7 +77,7 @@ outputs:
|
|||||||
template: |
|
template: |
|
||||||
nodes:
|
nodes:
|
||||||
hosts:
|
hosts:
|
||||||
{% for host in groups['ROLENAME'] -%}
|
{% for host in groups['ROLENAME'] | default([]) -%}
|
||||||
{{ hostvars.raw_get(host)['ansible_hostname'] }}:
|
{{ 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_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) }}
|
ansible_host: {{ hostvars.raw_get(host)['ansible_host'] | default(host) }}
|
||||||
|
Loading…
Reference in New Issue
Block a user