Invalid 'hosts.yaml' is generated when using multiple hosts
seumasdunlop opened this issue · comments
There is a missing colon at the end of the hostname in the children.kubitect_hosts.hosts
section so the separate hosts are concatenated to a single host.
E.g.
children:
kubitect_hosts:
hosts:
ubuntu-1
ubuntu-2
That generates the following error because it is trying to resolve 'ubuntu-1 ubuntu-2
':
fatal: [ubuntu-1 ubuntu-2]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ubuntu-1 ubuntu-2: Name or service not known", "unreachable": true}
Adding a trailing colon to the template fixes it. E.g.
children:
kubitect_hosts:
hosts:
{% if config.hosts is defined %}
{% for host in config.hosts %}
{{ host.name }}:
{% endfor %}
{% endif %}