Skip to content
Snippets Groups Projects
Unverified Commit cf3b3ca6 authored by R. P. Taylor's avatar R. P. Taylor Committed by GitHub
Browse files

clean up /etc/hosts file if populate_inventory_to_hosts_file is false (#10144)

* de-populate hosts file if populate_inventory_to_hosts_file is false

keep newline

* fix when condition
parent 1955943d
No related branches found
No related tags found
No related merge requests found
---
- name: Hosts | update inventory in hosts file
when: populate_inventory_to_hosts_file
block:
- name: Hosts | create list from inventory
- name: Hosts | create hosts list from inventory
set_fact:
etc_hosts_inventory_block: |-
{% for item in (groups['k8s_cluster'] + groups['etcd'] | default([]) + groups['calico_rr'] | default([])) | unique -%}
......@@ -21,7 +18,7 @@
blockinfile:
path: /etc/hosts
block: "{{ hostvars.localhost.etc_hosts_inventory_block }}"
state: present
state: "{{ 'present' if populate_inventory_to_hosts_file else 'absent' }}"
create: yes
backup: yes
unsafe_writes: yes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment