Fix wrong when condition that ends up with jinja error when the content of /etc/hosts contains parenthesis
This commit is contained in:
parent
7efe287c74
commit
b395bb953f
1 changed files with 2 additions and 2 deletions
|
@ -30,12 +30,12 @@
|
||||||
- name: Hosts | Extract existing entries for localhost from hosts file
|
- name: Hosts | Extract existing entries for localhost from hosts file
|
||||||
set_fact:
|
set_fact:
|
||||||
etc_hosts_localhosts_dict: >-
|
etc_hosts_localhosts_dict: >-
|
||||||
{%- set splitted = (item | regex_replace('[ ]+', ' ')|regex_replace('#.+$')|trim).split( ' ') -%}
|
{%- set splitted = (item | regex_replace('[ \t]+', ' ')|regex_replace('#.*$')|trim).split( ' ') -%}
|
||||||
{{ etc_hosts_localhosts_dict|default({}) | combine({splitted[0]: splitted[1::] }) }}
|
{{ etc_hosts_localhosts_dict|default({}) | combine({splitted[0]: splitted[1::] }) }}
|
||||||
with_items: "{{ (etc_hosts_content['content'] | b64decode).split('\n') }}"
|
with_items: "{{ (etc_hosts_content['content'] | b64decode).split('\n') }}"
|
||||||
when:
|
when:
|
||||||
- etc_hosts_content.content is defined
|
- etc_hosts_content.content is defined
|
||||||
- etc_hosts_localhost_entries.keys()|map('regex_replace', '(.*)', '^\\1 .*') | map('match', item) | list | length > 0
|
- (item|match('^::1 .*') or item|match('^127.0.0.1 .*'))
|
||||||
|
|
||||||
- name: Hosts | Update target hosts file entries dict with required entries
|
- name: Hosts | Update target hosts file entries dict with required entries
|
||||||
set_fact:
|
set_fact:
|
||||||
|
|
Loading…
Reference in a new issue