Damned, cloud-init is messing with /etc/hosts...
This commit is contained in:
parent
5db7cca782
commit
19b5776760
|
@ -4,20 +4,31 @@
|
|||
hostname:
|
||||
name: "{{ inventory_hostname_short }}"
|
||||
|
||||
- name: Configure localhots
|
||||
- name: Configure localhost
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: '^127\.0\.0\.1'
|
||||
line: "127.0.0.1 localhost"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Configure FQDN
|
||||
lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: '^127\.0\.1\.1'
|
||||
line: "127.0.1.1 {{ inventory_hostname }} {{ inventory_hostname_short }}"
|
||||
|
||||
- name: Check if cloud-init is installed
|
||||
ansible.builtin.stat:
|
||||
path: /etc/cloud/cloud.cfg.d/
|
||||
register: cloud_cfg
|
||||
|
||||
- name: Stop cloud-init to change hostname and /etc/hosts
|
||||
when: cloud_cfg.stat.isdir is defined and cloud_cfg.stat.isdir
|
||||
copy:
|
||||
content: |
|
||||
# Managed by Ansible
|
||||
preserve_hostname: true
|
||||
manage_etc_hosts: false
|
||||
dest: /etc/cloud/cloud.cfg.d/02_ansible.cfg
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
exim4_sendonly_fqdn: '{{ ansible_fqdn }}'
|
||||
exim4_sendonly_fqdn: '{{ inventory_hostname }}'
|
||||
|
||||
exim4_sendonly_smarthost: ''
|
||||
exim4_sendonly_username: ''
|
||||
|
|
Loading…
Reference in New Issue