Skip to content
Snippets Groups Projects
Unverified Commit 58ecd312 authored by k8s-ci-robot's avatar k8s-ci-robot Committed by GitHub
Browse files

Merge pull request #3186 from mirwan/fix_etchosts_localhost_handling

Fix localhost handling when /etc/hosts contains parenthesis
parents 7efe287c b395bb95
No related branches found
No related tags found
No related merge requests found
......@@ -30,12 +30,12 @@
- 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( ' ') -%}
{%- set splitted = (item | regex_replace('[ \t]+', ' ')|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
- (item|match('^::1 .*') or item|match('^127.0.0.1 .*'))
- name: Hosts | Update target hosts file entries dict with required entries
set_fact:
......
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