Updating the playbook to edit the hostname

This commit is contained in:
Lucas Costa Beyeler 2017-02-03 23:42:15 -02:00
parent cf74da8404
commit f996ae57b8
4 changed files with 18 additions and 6 deletions

View File

@ -23,12 +23,6 @@ install:
# Create ansible.cfg with correct roles_path # Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg - printf '[defaults]\nroles_path=../' >ansible.cfg
# Include the domain inside the /etc/hosts
- printf '127.0.0.1 localhost.localdomain localhost' > /etc/hosts
# Change the hostname
- hostnamectl set-hostname 'localhost.localdomain'
script: script:
# Basic role syntax check # Basic role syntax check

View File

@ -10,6 +10,7 @@
# #
# Starting the install # Starting the install
################################### ###################################
- include: nodistro/hostname.yml
- include: '{{ ansible_os_family }}/packages.yml' - include: '{{ ansible_os_family }}/packages.yml'
- include: nodistro/install-zimbra.yml - include: nodistro/install-zimbra.yml
- include: nodistro/install-spamassassin.yml - include: nodistro/install-spamassassin.yml

View File

@ -0,0 +1,14 @@
# Change the hostname and ensure the /etc/hosts has the hostname linked to the
# localhost. This is very important for some services, like Zimbra, who will
# check for the LDAP Server's IP.
- name: Correct the machine's hostname to {{ hostname }}
hostname: name='{{ hostname }}.{{ domain }}'
- name: Changing the host's file for the template
template:
src: hosts.j2
dest: /etc/hosts
owner: root
group: root
mode: 0644

3
templates/hosts.j2 Normal file
View File

@ -0,0 +1,3 @@
::1 localhost.localdomain localhost
127.0.0.1 localhost.localdomain localhost
127.0.0.1 {{ hostname }}.{{ domain }} {{ hostname }}