From 6f25d6fc323aa3fb577ccc29b2cc7ee494416f75 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Sat, 27 Jun 2020 05:22:31 +0200 Subject: [PATCH] vm ip config --- tasks/ssh.yaml | 12 ++++++++++++ templates/ssh.config.j2 | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 templates/ssh.config.j2 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 %}