Created
October 4, 2018 17:54
-
-
Save voyager123bg/7f8bd9b04d1e6d6d6e55831ac1022dba to your computer and use it in GitHub Desktop.
ansible host file generator - add private ip for inventory 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
- name: "Build hosts file" | |
lineinfile: | |
path: /etc/hosts | |
regexp: '.*{{ item }}$' | |
line: "{{ hostvars[item]['ansible_default_ipv4']['address'] }} {{ item }}" | |
state: present | |
with_items: | |
- "{{ groups['mongo-config'] }}" | |
- "{{ groups['mongo-shards'] }}" | |
- "{{ groups['mongo-main'] }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment