Merge branch 'master' of adellam/ansible-roles into master

This commit is contained in:
Andrea Dell'Amico 2019-10-25 19:50:12 +02:00 committed by Gitea
commit c18af588f8
1 changed files with 6 additions and 1 deletions

View File

@ -1,9 +1,14 @@
---
- name: Set the hostname
- name: Set the hostname when different from the inventory one.
hostname: name={{ hostname }}
when: hostname is defined
tags: [ 'bootstrap', 'set_hostname' ]
- name: Set the hostname as defined in the inventory
hostname: name={{ inventory_hostname }}
when: hostname is not defined
tags: [ 'bootstrap', 'set_hostname' ]
- name: Add the hostname to /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: