Skip to content

Commit

Permalink
Fix regexp match on /etc/hosts for standalone nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
lae committed Sep 8, 2021
1 parent eda519e commit fbe315c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fbe315c

Please sign in to comment.