Added role hostname
parent
596c03fe22
commit
3910b1bac6
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
hostname: "{{ fqdn | regex_replace('^([^\\.]*)\\..*$', '\\1') }}"
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: restart systemd-hostnamed
|
||||||
|
systemd:
|
||||||
|
name: systemd-hostnamed
|
||||||
|
state: restarted
|
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Set local hostname
|
||||||
|
copy:
|
||||||
|
content: "{{ hostname }}"
|
||||||
|
dest: /etc/hostname
|
||||||
|
notify: restart systemd-hostnamed
|
||||||
|
|
||||||
|
- name: Set hostname and fqdn as alias for ipv4
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/hosts
|
||||||
|
regexp: '^127\.0\.0\.1\s'
|
||||||
|
line: "127.0.0.1 {{ fqdn }} {{ hostname }} localhost *.localhost"
|
||||||
|
notify: restart systemd-hostnamed
|
||||||
|
|
||||||
|
- name: Set hostname and fqdn as alias for ipv6
|
||||||
|
lineinfile:
|
||||||
|
path: /etc/hosts
|
||||||
|
regexp: '^::1\s'
|
||||||
|
line: "::1 {{ fqdn }} {{ hostname }} localhost *.localhost ip6-localhost ip6-loopback"
|
||||||
|
notify: restart systemd-hostnamed
|
||||||
|
|
||||||
|
- meta: flush_handlers
|
Loading…
Reference in New Issue