Skip to content

Commit

Permalink
role hostname: Change hostname in /etc/hosts for localhost only
Browse files Browse the repository at this point in the history
in some cases, the ansible_default_ipv4.address variable may be missing
  • Loading branch information
vitabaks committed Jan 17, 2023
1 parent 9567520 commit 42840a2
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion roles/hostname/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
no_log: true
loop:
- { regexp: '^127\.0\.0\.1[ \t]+localhost', line: '127.0.0.1 localhost {{ ansible_hostname }}' }
- { regexp: '^{{ ansible_default_ipv4.address }}.+$', line: '{{ ansible_default_ipv4.address }} {{ ansible_hostname }}' }
when: hostname is defined and hostname | length > 0
tags: hostname

Expand Down

0 comments on commit 42840a2

Please sign in to comment.