Skip to content

Commit

Permalink
Update /etc/hosts with hostnames of swarm
Browse files Browse the repository at this point in the history
  • Loading branch information
drmalex07 committed Sep 11, 2017
1 parent 9bae664 commit bddb140
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions play.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
assert:
that: primary_ipv4_address == ipv4_address

- name: Guess hostname if missing
- name: Set default hostname if not supplied
set_fact:
hostname: '{{ansible_host}}'
when: not (hostname is defined)
Expand All @@ -36,11 +36,18 @@

tasks:

#- debug: var=play_hosts
#- debug: var=network
#- debug: var=hostname
- debug: var=play_hosts
#- debug: var=network
#- debug: var=hostname

#- debug: var=listen_address
#- debug: var=primary_ipv4_address
#- debug: var=ipv4_address

#- debug: var=listen_address
#- debug: var=primary_ipv4_address
#- debug: var=ipv4_address

- name: Update /etc/hosts with hostnames of this swarm
lineinfile:
dest: /etc/hosts
line: '{{hostvars[item].ipv4_address}} {{hostvars[item].hostname}} {{item}}'
insertafter: '^127\.0\.1\.1 .*'
with_items: '{{play_hosts}}'
sudo: yes

0 comments on commit bddb140

Please sign in to comment.