Skip to content
Snippets Groups Projects
Commit e38dca55 authored by jurgenhaas's avatar jurgenhaas
Browse files

Improve handling of /etc/hosts files

parent c378dea5
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,20 @@
mode='644'
with_flattened:
- '{{ admins }}'
- '{{ jailusers }}'
- '{{ jailusers|default([]) }}'
- name: "a1"
shell: ls ~/.ansible/hostvars
become: no
register: fact_files
failed_when: false
changed_when: false
ignore_errors: true
- include: more.yml
with_items: '{{ fact_files.stdout_lines|default([]) }}'
loop_control:
loop_var: inventory_name
- name: 'Remember that this role had been run'
set_fact: role_commonconnect_completed=true
......
---
# file: roles/commonconnect/tasks/more.yml
- name: "Read facts"
shell: cat ~/.ansible/hostvars/{{ inventory_name }}
become: no
register: result_facts
- set_fact: facts="{{ result_facts.stdout | from_json }}"
- name: "Add Hosts to Hostfile"
lineinfile:
dest='/etc/hosts'
regexp='.* {{ item }}$'
line='{{ facts[item].static_ipv4 }} {{ item }}'
state=present
with_items: '{{ facts }}'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment