Set the provided hostname when it's defined.

This commit is contained in:
Andrea Dell'Amico 2017-09-12 15:33:56 +02:00
parent 7ea507790f
commit e955566e16
1 changed files with 1 additions and 1 deletions

View File

@ -5,6 +5,6 @@
tags: bootstrap
- name: Add the hostname to /etc/hosts
shell: grep -v {{ ansible_default_ipv4.address }} /etc/hosts > /etc/hosts.tmp ; echo "{{ ansible_default_ipv4.address }} {{ ansible_fqdn }} {{ ansible_hostname }}" >> /etc/hosts.tmp ; /bin/mv /etc/hosts.tmp /etc/hosts
shell: grep -v {{ ansible_default_ipv4.address }} /etc/hosts > /etc/hosts.tmp ; echo "{{ ansible_default_ipv4.address }} {{ hostname }} {{ ansible_hostname }}" >> /etc/hosts.tmp ; /bin/mv /etc/hosts.tmp /etc/hosts
when: hostname is defined
tags: bootstrap