Initial commit
This commit is contained in:
17
tasks/set-hostname.yml
Normal file
17
tasks/set-hostname.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Set the hostname
|
||||
ansible.builtin.hostname:
|
||||
name: "{{ inventory_hostname }}"
|
||||
|
||||
- name: Replace double home with hostname (if present)
|
||||
ansible.builtin.replace:
|
||||
path: /etc/hosts
|
||||
regexp: 127\.0\.1\.1
|
||||
replace: "{{ ansible_host }} {{ inventory_hostname }}"
|
||||
|
||||
- name: Ensure at least one full hostname entry is present
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/hosts
|
||||
regexp: "{{ ansible_host }}.*{{ inventory_hostname }}"
|
||||
line: "{{ ansible_host }} {{ inventory_hostname }}"
|
||||
state: present
|
||||
Reference in New Issue
Block a user