diff --git a/hshbase/hostname/files/hosts b/hshbase/hostname/files/hosts new file mode 100644 index 0000000000000000000000000000000000000000..20d45e379eedbb3aea67ec3d1b73603940493347 --- /dev/null +++ b/hshbase/hostname/files/hosts @@ -0,0 +1,20 @@ +### 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 %} diff --git a/hshbase/hostname/init.sls b/hshbase/hostname/init.sls new file mode 100644 index 0000000000000000000000000000000000000000..4a4c62e25ef4d560ed3d0992386c8f361337d2f5 --- /dev/null +++ b/hshbase/hostname/init.sls @@ -0,0 +1,12 @@ + +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 diff --git a/hshbase/init.sls b/hshbase/init.sls index 706fd03c696e28349a73cb608bc127c0777bf242..06815f1cae0beaba17e688f36e91530d99902a69 100644 --- a/hshbase/init.sls +++ b/hshbase/init.sls @@ -8,3 +8,4 @@ include: - .openvmtools - .time - .locale + - .hostname