From 29c65bcc0859ae1b6b3b21756cc2298df92534a6 Mon Sep 17 00:00:00 2001 From: Sergey Bubnov Date: Wed, 21 Nov 2018 10:14:52 +0400 Subject: [PATCH] register all nodes in /etc/hosts --- provision.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/provision.yml b/provision.yml index 4e977c2..dea8b43 100644 --- a/provision.yml +++ b/provision.yml @@ -22,7 +22,7 @@ - name: prepare nodes hosts: stack gather_facts: false - # cannot use free strategy due usage of add_host after + # cannot use free strategy due usage of add_host after # NICs reconfiguration #strategy: free pre_tasks: @@ -54,4 +54,11 @@ owner: root group: root mode: 0644 + - name: register nodes in /etc/hosts + lineinfile: + dest: /etc/hosts regexp=".*{{ item }}$" + line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }}" + state: present + when: hostvars[item].ansible_default_ipv4.address is defined + with_items: play_hosts tags: [ prepare ]