- 
      
 - 
        
Save IssacTran/a99b94674430dad14a6b91570ac701a9 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
rothgar revised this gist
Feb 3, 2014 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ # Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source. # Will include all hosts the playbook is run on. # Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html - name: "Build hosts file" lineinfile: dest=/etc/hosts regexp='.*{{ item }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{item}}" state=present  - 
        
rothgar revised this gist
Feb 3, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Idempotent way to build a /etc/hosts file with Ansible using your Ansible hosts inventory for a source. Will include all hosts the playbook is run on. Inspired from http://xmeblog.blogspot.com/2013/06/ansible-dynamicaly-update-etchosts.html - name: "Build hosts file" 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  - 
        
rothgar revised this gist
Feb 3, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ - name: "Build hosts file" 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: groups['all']  - 
        
rothgar created this gist
Feb 3, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ - name: "Build hosts file" 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: groups['all']