diff --git a/tasks/main.yml b/tasks/main.yml index 4eb25319dc4dbeed75d2f1629aafabbb08131ace..6221bbffbab4b7b3a6d915e8ef05d09b8c28611a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,7 +9,7 @@ - name: "Create The /etc/hosts File" template: - src: 'etc_hosts' + src: 'etc_hosts.jinja2' dest: '/etc/hosts' owner: 'root' group: 'root' @@ -17,7 +17,7 @@ - name: "Copy SSH Config For Server-To-Server Communication For Admins" template: - src: 'ssh_config' + src: 'ssh_config.jinja2' dest: '/home/{{ item }}/.ssh/config' owner: '{{ item }}' group: 'root' diff --git a/templates/etc_hosts b/templates/etc_hosts.jinja2 similarity index 90% rename from templates/etc_hosts rename to templates/etc_hosts.jinja2 index ce413a4e46d208d12ad2a7ffa64e616a49a1d8a1..e4201d9c76772f68642bd5420acc36984a5446ac 100644 --- a/templates/etc_hosts +++ b/templates/etc_hosts.jinja2 @@ -46,9 +46,9 @@ ff02::2 ip6-allrouters {% endif %} {% endfor %} -{% for host in commonauth_extras|default([]) %} +{% for hostname, host in (commonauth_extras|default([])).iteritems() %} {% if host.ip is defined %} -{{host.ip}}{% for name in host['names'] %} {{name}}{% endfor %} -{% endif %} +{{ host.ip }} {{ hostname }}{% for alias in host.aliases|default([]) %} {{ alias }}{% endfor %} +{% endif %} {% endfor %} diff --git a/templates/ssh_config b/templates/ssh_config deleted file mode 100644 index af81dc03fcb6327871bc930bfdfa1765718a5947..0000000000000000000000000000000000000000 --- a/templates/ssh_config +++ /dev/null @@ -1,18 +0,0 @@ -# See all parameters at http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config - -StrictHostKeyChecking no -ForwardAgent no - -{% for host in commonauth_extras|default([]) %} -{% if host.ssh is defined %} -{% for name in host.names %} -Host {{ name }} -{% for key, value in host.ssh.iteritems() %} - {{ key }} {{ value }} -{% endfor %} - -{% endfor %} -{% endif %} -{% endfor %} -Host * - IdentityFile ~/.ssh/id_rsa diff --git a/templates/ssh_config.jinja2 b/templates/ssh_config.jinja2 new file mode 100644 index 0000000000000000000000000000000000000000..9440e6ef1bf59dcf285092e0b9b81a9e7dfd1813 --- /dev/null +++ b/templates/ssh_config.jinja2 @@ -0,0 +1,25 @@ +# See all parameters at http://www.openbsd.org/cgi-bin/man.cgi?query=ssh_config + +StrictHostKeyChecking no +ForwardAgent no + +{% if commonauth_extras is defined %} +{% for hostname, host in commonauth_extras.iteritems() %} +{% if host.ssh is defined or host.proxy is defined %} +Host {{ hostname }}{% for alias in host.aliases|default([]) %} {{ alias }}{% endfor %} + +{% if host.ssh is defined %} +{% for key, value in host.ssh.iteritems() %} + {{ key }} {{ value }} +{% endfor %} +{% endif %} +{% if host.proxy is defined %} + ForwardAgent yes + ProxyCommand /usr/bin/ssh {{ host.proxy }} /bin/nc %h %p +{% endif %} + +{% endif %} +{% endfor %} +{% endif %} +Host * + IdentityFile ~/.ssh/id_rsa