@@ -20,6 +20,10 @@ Salt Stack Formula to set up and configure a host's network configuration | |||
## Available states | |||
### network.hosts | |||
Sets the static lookup table for hostnames | |||
### network.interfaces | |||
Sets the network interfaces configuration |
@@ -4,10 +4,38 @@ Debian: | |||
enabled: True | |||
proto: dhcp | |||
type: eth | |||
resolver: | |||
path: /etc/resolv.conf | |||
default_interfaces: | |||
- name: lo | |||
proto: loopback | |||
type: eth | |||
resolver_defaults: | |||
path: /etc/resolv.conf | |||
host_defaults: | |||
path: /etc/hosts | |||
ensure: present | |||
default_hosts: | |||
- name: localhost | |||
ip: 127.0.0.1 | |||
- name: localhost.localdomain | |||
ip: 127.0.0.1 | |||
- name: localhost | |||
ip: ::1 | |||
- name: ip6-localhost | |||
ip: ::1 | |||
- name: ip6-loopback | |||
ip: ::1 | |||
- name: ip6-localnet | |||
ip: fe00::0 | |||
- name: ip6-mcastprefix | |||
ip: ff00::0 | |||
- name: ip6-allnodes | |||
ip: ff02::1 | |||
- name: ip6-allrouters | |||
ip: ff02::2 | |||
- name: ip6-allhosts | |||
ip: ff02::3 | |||
- name: {{ salt['grains.get']('fqdn') }} | |||
ip: 127.0.1.1 | |||
- name: {{ salt['grains.get']('host') }} | |||
ip: 127.0.1.1 | |||
{% endload %} |
@@ -0,0 +1,16 @@ | |||
{% from "network/defaults.yaml" import rawmap with context %} | |||
{% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %} | |||
{% set hosts = datamap['default_hosts'] %} | |||
{% if salt['pillar.get']('network:hosts', False) %} | |||
{% set hosts = hosts + salt['pillar.get']('network:hosts') %} | |||
{% endif %} | |||
{% for h in hosts %} | |||
host-{{ h['name'] }}_{{ h['ip'] }}: | |||
host: | |||
- {{ h['ensure']|default(datamap['host_defaults']['ensure']) }} | |||
- ip: {{ h['ip'] }} | |||
- name: {{ h['name'] }} | |||
{% endfor %} |
@@ -4,7 +4,7 @@ | |||
resolver: | |||
file: | |||
- managed | |||
- name: {{ datamap['resolver']['path'] }} | |||
- name: {{ datamap['resolver_defaults']['path'] }} | |||
- mode: '0644' | |||
- user: root | |||
- group: root |
@@ -20,3 +20,12 @@ network: | |||
options: | |||
- rotate | |||
- timeout:1 | |||
hosts: | |||
- name: example.com | |||
ip: 192.168.2.100 | |||
- name: example.org | |||
ip: 192.168.2.150 | |||
ensure: present | |||
- name: example.net | |||
ip: 192.168.2.200 | |||
ensure: absent |