From 063afb9e11e450d5523eb822eb9df9aec20064cd Mon Sep 17 00:00:00 2001 From: Cedric Girard Date: Wed, 14 Nov 2018 18:56:34 +0100 Subject: [PATCH] playbook to update etc/hosts file --- update_host_file.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 update_host_file.yml diff --git a/update_host_file.yml b/update_host_file.yml new file mode 100644 index 0000000..fc31220 --- /dev/null +++ b/update_host_file.yml @@ -0,0 +1,17 @@ +- hosts: + - OSEv3 + - localhost + become: true + tasks: + - name: debug hostvars for OSEv3 group + debug: + var: "{{ hostvars }}" + verbosity: 3 + - name: Update /etc/hosts file with all nodes + blockinfile: + path: /etc/hosts + block: | + {% for item in groups['OSEv3'] %} + {{ hostvars[item]['ansible_default_ipv4']['address'] }} {{ item }} + {% endfor %} +