Skip to content
Snippets Groups Projects
Commit eaed2952 authored by Lars Beckers's avatar Lars Beckers
Browse files

basic-system: add management of /etc/hosts

parent 27ea6bba
No related branches found
No related tags found
No related merge requests found
---
dns_hostname_fqdn: False
hosts_alternates: []
hosts_additionals: []
......@@ -9,3 +9,7 @@
- name: update initramfs
command: update-initramfs -u
- name: gather network facts once again
setup: gather_subset=network
......@@ -17,6 +17,8 @@
- name: ensure the hostname is not a fqdn
hostname: name="{{ inventory_hostname }}"
when: not dns_hostname_fqdn
notify:
- gather network facts once again
tags:
- dns
- network
......@@ -25,11 +27,25 @@
- name: ensure the hostname is a fqdn
hostname: name="{{ ansible_fqdn }}"
when: dns_hostname_fqdn
notify:
- gather network facts once again
tags:
- dns
- network
- config
- meta: flush_handlers
- name: ensure correct hosts file
template:
src: hosts.j2
dest: /etc/hosts
notify:
- gather network facts once again
tags:
- dns
- network
- name: ensure deactivation of tcp_timestamps
sysctl: name=net.ipv4.tcp_timestamps value=0 state=present sysctl_set=yes
tags:
......
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
{%- for host in hosts_alternates %}
{{ host }} {{ ansible_host }} {{ inventory_hostname }}
{% else %}
{{ ansible_default_ipv4.address }} {{ ansible_host }} {{ inventory_hostname }}
{%- if address in ansible_default_ipv6 %}
{{ ansible_default_ipv6.address }} {{ ansible_host }} {{ inventory_hostname }}
{% endif -%}
{% endfor -%}
{%- for host in hosts_additionals %}
{{ host.address }} {{ host.names|join(' ') }}
{% endfor -%}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment