Created
August 26, 2015 15:32
-
-
Save frodopwns/46b138837cc44250c32b to your computer and use it in GitHub Desktop.
push hostnames to all ansible hosts
This file contains 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 characters
- hosts: all | |
sudo: yes | |
tasks: | |
- name: "Build hosts file" | |
lineinfile: | |
dest=/etc/hosts | |
regexp=".*{{ item }}$" | |
line="{{ hostvars[item].ansible_eth1.ipv4.address }} {{item}}" | |
state=present | |
when: hostvars[item].ansible_eth1.ipv4.address is defined | |
with_items: groups['all'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment