From fbe315c57c0856e8048c35074efb6fb16d6bbb93 Mon Sep 17 00:00:00 2001 From: Musee Ullah Date: Wed, 25 Aug 2021 07:33:43 -0500 Subject: [PATCH] Fix regexp match on /etc/hosts for standalone nodes --- tasks/main.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 40ff59b9..1445a589 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -81,16 +81,16 @@ - name: Define hostname in /etc/hosts for single-host installations lineinfile: dest: /etc/hosts - regexp: |- - {# Match an IPv4/v6 address at the start #} - ^\\h*[0-9a-f:.]+ - {# Match at least one whitespace, and any non-hostname names #} - (\\h+.*)?\\h - {# Match either our fqdn or hostname #} - ({{ ansible_fqdn | regex_escape() }}|{{ ansible_hostname | regex_escape() }}) - {# Require there be a word boundary at the end of the name(s). #} - {# This can be any whitespace, or end-of-line. #} - (\\h+.*|\\h*)$ + regexp: "\ + {# Match an IPv4/v6 address at the start #}\ + ^\\s*[0-9a-f:.]+\ + {# Match at least one whitespace, and any non-hostname names #}\ + (\\s+.*)*\\s\ + {# Match either our fqdn or hostname #}\ + ({{ ansible_fqdn | regex_escape() }}|{{ ansible_hostname | regex_escape() }})\ + {# Require there be a word boundary at the end of the name(s). #}\ + {# This can be any whitespace, or end-of-line. #}\ + (\\s+.*|\\s*)$" line: "{{ hostvars[inventory_hostname].pve_cluster_addr0 }} {{ ansible_fqdn }} {{ ansible_hostname }}" backup: yes when: "not pve_cluster_enabled | bool and pve_manage_hosts_enabled | bool"