handle both 'ansible_host' and 'ansible_ssh_host' in bastion configuration

'absible_ssh_host' is deprecated in Ansible 2.0 and at least
'contrib/inventory_builder/inventory.py' uses 'ansible_host' instead.
This commit is contained in:
Vladimir Rutsky 2017-02-02 18:33:05 +03:00
parent ae66b6e648
commit b4327fdc99

View file

@ -4,7 +4,7 @@
{% for h in groups['all'] %}
{% if h != 'bastion' %}
{% if vars.update({'hosts': vars['hosts'] + ' ' + hostvars[h]['ansible_ssh_host']}) %}{% endif %}
{% if vars.update({'hosts': vars['hosts'] + ' ' + (hostvars[h].get('ansible_ssh_host') or hostvars[h]['ansible_host'])}) %}{% endif %}
{% endif %}
{% endfor %}
@ -18,4 +18,4 @@ Host {{ bastion_ip }}
Host {{ vars['hosts'] }}
ProxyCommand ssh -W %h:%p {{ real_user }}@{{ bastion_ip }}
StrictHostKeyChecking no
{% endif %}
{% endif %}