Added role hostname

wip
Felix Stupp 5 years ago
parent 596c03fe22
commit 3910b1bac6
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -12,3 +12,4 @@ Following roles have been defined to make creating a server configuration easy:
- **certificate** issues a given certificate
- **bootstrap** defines a way to connect to a server which has not been configured yet
- **common** defines the installation of common packages and common configurations like firewall
- **hostname** configures the hostname for a given host

@ -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…
Cancel
Save