Damned, cloud-init is messing with /etc/hosts...
This commit is contained in:
parent
5db7cca782
commit
19b5776760
|
@ -4,20 +4,31 @@
|
||||||
hostname:
|
hostname:
|
||||||
name: "{{ inventory_hostname_short }}"
|
name: "{{ inventory_hostname_short }}"
|
||||||
|
|
||||||
- name: Configure localhots
|
- name: Configure localhost
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /etc/hosts
|
path: /etc/hosts
|
||||||
regexp: '^127\.0\.0\.1'
|
regexp: '^127\.0\.0\.1'
|
||||||
line: "127.0.0.1 localhost"
|
line: "127.0.0.1 localhost"
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Configure FQDN
|
- name: Configure FQDN
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /etc/hosts
|
path: /etc/hosts
|
||||||
regexp: '^127\.0\.1\.1'
|
regexp: '^127\.0\.1\.1'
|
||||||
line: "127.0.1.1 {{ inventory_hostname }} {{ inventory_hostname_short }}"
|
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
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: 0644
|
mode: 0644
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
exim4_sendonly_fqdn: '{{ ansible_fqdn }}'
|
exim4_sendonly_fqdn: '{{ inventory_hostname }}'
|
||||||
|
|
||||||
exim4_sendonly_smarthost: ''
|
exim4_sendonly_smarthost: ''
|
||||||
exim4_sendonly_username: ''
|
exim4_sendonly_username: ''
|
||||||
|
|
Loading…
Reference in New Issue
Block a user