diff --git a/roles/commonVars/vars/main.yml b/roles/commonVars/vars/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..8faa3c3c117df7693ebf8d4aff2cd6283e5766d1 --- /dev/null +++ b/roles/commonVars/vars/main.yml @@ -0,0 +1,2 @@ +--- +domain: testdomain.massive.org.au diff --git a/roles/etcHosts/tasks/main.yml b/roles/etcHosts/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..f527a58950bcd0543c321856255738f734096518 --- /dev/null +++ b/roles/etcHosts/tasks/main.yml @@ -0,0 +1,19 @@ +- name: get_groups_json + template: dest=/tmp/groups src=groups.j2 + run_once: True + delegate_to: 127.0.0.1 + +- name: make hosts data + command: ./scripts/makehosts.py /tmp/groups {{ domain }} + delegate_to: 127.0.0.1 + run_once: True + register: hosts_data + +- name: write hosts file + lineinfile: + args: + dest: /etc/hosts + line: "{{ item }}" + state: present + sudo: true + with_items: hosts_data.stdout_lines diff --git a/roles/etcHosts/templates/groups.j2 b/roles/etcHosts/templates/groups.j2 new file mode 100644 index 0000000000000000000000000000000000000000..dffc1333690bb0a0495cdd0c5c4b2f9f8c1bd509 --- /dev/null +++ b/roles/etcHosts/templates/groups.j2 @@ -0,0 +1,4 @@ +{ + "groups": {{ groups | to_nice_json }}, + "hostvars": {{ hostvars | to_nice_json }} +} diff --git a/roles/resolveHosts/meta/main.yml b/roles/resolveHosts/meta/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..6d22a32f83854bd1cc980aafcf562e1abf7915b7 --- /dev/null +++ b/roles/resolveHosts/meta/main.yml @@ -0,0 +1,5 @@ +--- +dependencies: + - { role: commonVars } + - { role: etcHosts } +