Skip to content
Snippets Groups Projects
Commit b854644d authored by Jan Philipp Timme's avatar Jan Philipp Timme
Browse files

Add new state to manage /etc/hostname and /etc/hosts

parent 28d5425b
Branches
No related tags found
No related merge requests found
### THIS FILE IS MANAGED BY SALT!
### YOUR CHANGES WILL BE OVERWRITTEN!
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
{%- set fqdn = grains['id'] -%}
{%- set localname = '' -%}
{%- if '.' in grains['id'] -%}
{%- set localname = fqdn.split('.')[0] -%}
{%- endif %}
{% for ip in grains['ipv4'] -%}
{%- if ip != '127.0.0.1'%}
{{ ip }} {{ fqdn }} {{ localname }}
{%- endif %}
{%- endfor %}
hsh_etc_hostname_content:
file.managed:
- name: /etc/hostname
- contents: |
{{ grains['id'] }}
hsh_etc_hosts_content:
file.managed:
- name: /etc/hosts
- template: jinja
- source: salt://hshbase/hostname/files/hosts
......@@ -8,3 +8,4 @@ include:
- .openvmtools
- .time
- .locale
- .hostname
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment