Skip to content

Instantly share code, notes, and snippets.

@voyager123bg
Created October 4, 2018 17:54
Show Gist options
  • Save voyager123bg/7f8bd9b04d1e6d6d6e55831ac1022dba to your computer and use it in GitHub Desktop.
Save voyager123bg/7f8bd9b04d1e6d6d6e55831ac1022dba to your computer and use it in GitHub Desktop.
ansible host file generator - add private ip for inventory hosts
- 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