From 13cd279f879ddebee2473903fdbb5375954cd5f5 Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Tue, 10 Jan 2017 16:11:08 +0100 Subject: [PATCH] New script to update hosts file and ssh config locally --- tasks/main.yml | 22 +++++++++++----------- tasks/more.yml | 8 ++++---- templates/etc_hosts | 2 ++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index d16f580..8923553 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,21 +9,21 @@ - name: "Create The /etc/hosts File" template: - src='etc_hosts' - dest='/etc/hosts' - owner='root' - group='root' - mode='644' + src: 'etc_hosts' + dest: '/etc/hosts' + owner: 'root' + group: 'root' + mode: '644' - name: "Copy SSH Config For Server-To-Server Communication For Admins" template: - src='ssh_config' - dest='/home/{{ item }}/.ssh/config' - owner='{{ item }}' - group='root' - mode='644' + src: 'ssh_config' + dest: '/home/{{ item }}/.ssh/config' + owner: '{{ item }}' + group: 'root' + mode: '644' with_flattened: - - '{{ admins }}' + - '{{ admins|default([]) }}' - '{{ jailusers|default([]) }}' - name: "Read available variable cache files" diff --git a/tasks/more.yml b/tasks/more.yml index bdd2654..91c1e67 100644 --- a/tasks/more.yml +++ b/tasks/more.yml @@ -10,8 +10,8 @@ - name: "Add Hosts to Hostfile" lineinfile: - dest='/etc/hosts' - regexp='.* {{ item }}$' - line='{{ facts[item].static_ipv4 }} {{ item }}' - state=present + dest: '/etc/hosts' + regexp: '.* {{ item }}$' + line: '{{ facts[item].static_ipv4 }} {{ item }}' + state: 'present' with_items: '{{ facts }}' diff --git a/templates/etc_hosts b/templates/etc_hosts index 68fdd19..ce413a4 100644 --- a/templates/etc_hosts +++ b/templates/etc_hosts @@ -47,6 +47,8 @@ ff02::2 ip6-allrouters {% endfor %} {% for host in commonauth_extras|default([]) %} +{% if host.ip is defined %} {{host.ip}}{% for name in host['names'] %} {{name}}{% endfor %} +{% endif %} {% endfor %} -- GitLab