|
@ -22,18 +22,33 @@ |
|
|
- loadbalancer_apiserver is defined |
|
|
- loadbalancer_apiserver is defined |
|
|
- loadbalancer_apiserver.address is defined |
|
|
- loadbalancer_apiserver.address is defined |
|
|
|
|
|
|
|
|
- name: Hosts | localhost ipv4 in hosts file |
|
|
|
|
|
lineinfile: |
|
|
|
|
|
dest: /etc/hosts |
|
|
|
|
|
line: "127.0.0.1 localhost localhost.localdomain" |
|
|
|
|
|
regexp: '^127.0.0.1.*$' |
|
|
|
|
|
state: present |
|
|
|
|
|
backup: yes |
|
|
|
|
|
|
|
|
- name: Hosts | Retrieve hosts file content |
|
|
|
|
|
slurp: |
|
|
|
|
|
src: /etc/hosts |
|
|
|
|
|
register: etc_hosts_content |
|
|
|
|
|
|
|
|
|
|
|
- name: Hosts | Extract existing entries for localhost from hosts file |
|
|
|
|
|
set_fact: |
|
|
|
|
|
etc_hosts_localhosts_dict: >- |
|
|
|
|
|
{%- set splitted = (item | regex_replace('[ ]+', ' ')|regex_replace('#.+$')|trim).split( ' ') -%} |
|
|
|
|
|
{{ etc_hosts_localhosts_dict|default({}) | combine({splitted[0]: splitted[1::] }) }} |
|
|
|
|
|
with_items: "{{ (etc_hosts_content['content'] | b64decode).split('\n') }}" |
|
|
|
|
|
when: |
|
|
|
|
|
- etc_hosts_content.content is defined |
|
|
|
|
|
- etc_hosts_localhost_entries.keys()|map('regex_replace', '(.*)', '^\\1 .*') | map('match', item) | list | length > 0 |
|
|
|
|
|
|
|
|
|
|
|
- name: Hosts | Update target hosts file entries dict with required entries |
|
|
|
|
|
set_fact: |
|
|
|
|
|
etc_hosts_localhosts_dict_target: >- |
|
|
|
|
|
{%- set target_entries = etc_hosts_localhosts_dict.get(item.key, []) | difference(item.value.get('unexpected' ,[])) -%} |
|
|
|
|
|
{{ etc_hosts_localhosts_dict_target|default({}) | combine({item.key: (target_entries + item.value.expected)|unique}) }} |
|
|
|
|
|
with_dict: "{{ etc_hosts_localhost_entries }}" |
|
|
|
|
|
|
|
|
- name: Hosts | localhost ipv6 in hosts file |
|
|
|
|
|
|
|
|
- name: Hosts | Update (if necessary) hosts file |
|
|
lineinfile: |
|
|
lineinfile: |
|
|
dest: /etc/hosts |
|
|
dest: /etc/hosts |
|
|
line: "::1 localhost6 localhost6.localdomain" |
|
|
|
|
|
regexp: '^::1.*$' |
|
|
|
|
|
|
|
|
line: "{{ item.key }} {{ item.value|join(' ') }}" |
|
|
|
|
|
regexp: "^{{ item.key }}.*$" |
|
|
state: present |
|
|
state: present |
|
|
backup: yes |
|
|
backup: yes |
|
|
|
|
|
with_dict: "{{ etc_hosts_localhosts_dict_target }}" |