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

Read inventory directly

parent 13cd279f
No related branches found
No related tags found
No related merge requests found
---
# 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 }}"
- set_fact: facts="{{ lookup('file','~/.ansible/hostvars/{{ inventory_name }}') | from_json }}"
- name: "Add Hosts to Hostfile"
lineinfile:
......@@ -14,4 +9,4 @@
regexp: '.* {{ item }}$'
line: '{{ facts[item].static_ipv4 }} {{ item }}'
state: 'present'
with_items: '{{ facts }}'
with_items: '{{ facts|default([]) }}'
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