.
This commit is contained in:
2
salt/states/hosts/files/hostname.jinja
Normal file
2
salt/states/hosts/files/hostname.jinja
Normal file
@@ -0,0 +1,2 @@
|
||||
{% set hostname = pillar['network']['hostname'] -%}
|
||||
{{ hostname }}
|
29
salt/states/hosts/files/hosts.jinja
Normal file
29
salt/states/hosts/files/hosts.jinja
Normal file
@@ -0,0 +1,29 @@
|
||||
{% set ip = pillar['network']['ip'] -%}
|
||||
{% set hostname = pillar['network']['hostname'] -%}
|
||||
{% set domain = pillar['network']['domain'] -%}
|
||||
#
|
||||
# hosts This file describes a number of hostname-to-address
|
||||
# mappings for the TCP/IP subsystem. It is mostly
|
||||
# used at boot time, when no name servers are running.
|
||||
# On small systems, this file can be used instead of a
|
||||
# "named" name server.
|
||||
# Syntax:
|
||||
#
|
||||
# IP-Address Full-Qualified-Hostname Short-Hostname
|
||||
#
|
||||
|
||||
127.0.0.1 localhost
|
||||
{{ ip }} {{ hostname }}.{{ domain }} {{ hostname }}
|
||||
# special IPv6 addresses
|
||||
::1 localhost ipv6-localhost ipv6-loopback
|
||||
|
||||
fe00::0 ipv6-localnet
|
||||
|
||||
ff00::0 ipv6-mcastprefix
|
||||
ff02::1 ipv6-allnodes
|
||||
ff02::2 ipv6-allrouters
|
||||
ff02::3 ipv6-allhosts
|
||||
|
||||
{% for host, ip in pillar['network']['hosts'].items() -%}
|
||||
{{ pillar['network']['ip'][0:-1] }}{{ ip }} {{ host }}.{{ domain }} {{ host }}
|
||||
{% endfor %}
|
24
salt/states/hosts/init.sls
Normal file
24
salt/states/hosts/init.sls
Normal file
@@ -0,0 +1,24 @@
|
||||
Configure hosts file:
|
||||
file.managed:
|
||||
- name: /etc/hosts
|
||||
- source: salt://hosts/files/hosts.jinja
|
||||
- template: jinja
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: "0644"
|
||||
|
||||
Configure hostname file:
|
||||
file.managed:
|
||||
- name: /etc/hostname
|
||||
- source: salt://hosts/files/hostname.jinja
|
||||
- template: jinja
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: "0644"
|
||||
|
||||
Run hostname command:
|
||||
cmd.run:
|
||||
- name: hostname {{ pillar['network']['hostname'] }}
|
||||
- onchanges:
|
||||
- file: Configure hosts file
|
||||
- file: Configure hostname file
|
Reference in New Issue
Block a user