Do not reference ansible_hostname if it is undefined

Change-Id: I59c3de74c41b97ed1803d82c69db52199f27393e
Closes-Bug: #1797117
This commit is contained in:
John Fulton 2018-10-10 15:12:26 +02:00
parent ec227891bd
commit d556fd68d8

View File

@ -387,12 +387,14 @@ outputs:
{{ ceph_group ~ 's:' }} {{ ceph_group ~ 's:' }}
hosts: hosts:
{% for host in groups['ceph_' ~ ceph_group] -%} {% for host in groups['ceph_' ~ ceph_group] -%}
{%- if hostvars.raw_get(host)['ansible_hostname'] is defined -%}
{%- if hostvars.raw_get(host)['ansible_hostname'] not in blacklisted_hostnames -%} {%- if hostvars.raw_get(host)['ansible_hostname'] not in blacklisted_hostnames -%}
{{ hostvars.raw_get(host)['ansible_hostname'] }}: {{ hostvars.raw_get(host)['ansible_hostname'] }}:
ansible_user: {{ hostvars.raw_get(host)['ansible_ssh_user'] | default('root') }} ansible_user: {{ 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) }}
ansible_become: true ansible_become: true
{% endif -%} {% endif -%}
{% endif -%}
{%- endfor -%} {%- endfor -%}
{%- endif -%} {%- endif -%}