Skip to content

Commit

Permalink
Slower, but more reliable way to build hosts on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
tjheeta committed Feb 13, 2015
1 parent 96997fb commit 69ad28f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@
- lineinfile: dest="/etc/tinc/nets.boot" line="{{ tinc_netname }}" state=present
notify: restart_tinc

# The facts aren't available on first run, so copy over all the ip addresses
- file: path=/etc/tinc/{{ tinc_netname }}/tmp state=directory mode=0755 recurse=true
- copy: src="{{ tinc_tmpdir}}/{{ tinc_netname }}/ip/" dest="/etc/tinc/{{ tinc_netname }}/tmp"

- name: "Build hosts file"
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item]['ansible_' + tinc_netname]['ipv4']['address'] }} {{ hostvars[item]['ansible_hostname']}}.{{ tinc_netname }}" state=present
with_items: play_hosts
lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ lookup('file', item) }} {{ item | basename }}.{{ tinc_netname }}" state=present
with_fileglob:
- "/etc/tinc/{{ tinc_netname }}/tmp/*"
tags: hostsfile

- file: dest="{{ tinc_tmpdir }}/{{ tinc_netname }}" state=absent
Expand Down

0 comments on commit 69ad28f

Please sign in to comment.