diff --git a/tasks/ssh.yaml b/tasks/ssh.yaml index b8927af..b0458d9 100644 --- a/tasks/ssh.yaml +++ b/tasks/ssh.yaml @@ -5,3 +5,15 @@ src: ~/ssh-keys/ dest: ~/ssh-keys mode: u=rw,g=,o= + +- name: ssh auto config + template: + src: ssh.config.j2 + dest: ~/.ssh/config.auto + +- name: include ssh auto config + lineinfile: + path: ~/.ssh/config + line: Include config.auto + insertbefore: BOF + create: true diff --git a/templates/ssh.config.j2 b/templates/ssh.config.j2 new file mode 100644 index 0000000..6fafa7a --- /dev/null +++ b/templates/ssh.config.j2 @@ -0,0 +1,4 @@ +{% for hostname in groups.vms %} +Host {{hostname}} + HostName {{hostvars[hostname].external_ip}} +{% endfor %}