## Available states | ## Available states | ||||
### network.hosts | |||||
Sets the static lookup table for hostnames | |||||
### network.interfaces | ### network.interfaces | ||||
Sets the network interfaces configuration | Sets the network interfaces configuration |
enabled: True | enabled: True | ||||
proto: dhcp | proto: dhcp | ||||
type: eth | type: eth | ||||
resolver: | |||||
path: /etc/resolv.conf | |||||
default_interfaces: | default_interfaces: | ||||
- name: lo | - name: lo | ||||
proto: loopback | proto: loopback | ||||
type: eth | 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 %} | {% endload %} |
{% 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 %} |
resolver: | resolver: | ||||
file: | file: | ||||
- managed | - managed | ||||
- name: {{ datamap['resolver']['path'] }} | |||||
- name: {{ datamap['resolver_defaults']['path'] }} | |||||
- mode: '0644' | - mode: '0644' | ||||
- user: root | - user: root | ||||
- group: root | - group: root |
options: | options: | ||||
- rotate | - rotate | ||||
- timeout:1 | - 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 |