## TODO | ## TODO | ||||
None | |||||
* Use more of the available options in interfaces.sls of network.managed | |||||
## Instructions | ## Instructions | ||||
## Available states | ## Available states | ||||
### network | |||||
### network.interfaces | |||||
Sets the network interfaces configuration | |||||
### network.resolver | |||||
\#TODO | |||||
Sets the resolver configuration | |||||
## Additional resources | ## Additional resources | ||||
*DOES* work on: | *DOES* work on: | ||||
* GNU/ Linux Debian Wheezy | |||||
* GNU/ Linux Debian Wheezy (Salt: 2014.1.0) |
{% load_yaml as rawmap %} | {% load_yaml as rawmap %} | ||||
Debian: | Debian: | ||||
defaults: | |||||
interface_defaults: | |||||
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 |
network: | network: | ||||
- managed | - managed | ||||
- name: {{ n['name'] }} | - name: {{ n['name'] }} | ||||
- enabled: {{ n['enabled']|default(datamap['defaults']['enabled']) }} | |||||
- proto: {{ n['proto']|default(datamap['defaults']['proto']) }} | |||||
- type: {{ n['type']|default(datamap['defaults']['type']) }} | |||||
- enabled: {{ n['enabled']|default(datamap['interface_defaults']['enabled']) }} | |||||
- proto: {{ n['proto']|default(datamap['interface_defaults']['proto']) }} | |||||
- type: {{ n['type']|default(datamap['interface_defaults']['type']) }} | |||||
{% if n['proto'] in ['static'] %} | {% if n['proto'] in ['static'] %} | ||||
{% if n['ipaddr'] is defined %} | {% if n['ipaddr'] is defined %} | ||||
- ipaddr: {{ n['ipaddr'] }} | - ipaddr: {{ n['ipaddr'] }} |
{% from "network/defaults.yaml" import rawmap with context %} | |||||
{% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %} | |||||
resolver: | |||||
file: | |||||
- managed | |||||
- name: {{ datamap['resolver']['path'] }} | |||||
- mode: '0644' | |||||
- user: root | |||||
- group: root | |||||
- contents: | | |||||
{%- if salt['pillar.get']('network:resolver:file_prepend') is defined %} | |||||
{{ salt['pillar.get']('network:resolver:file_prepend') }} | |||||
{%- endif -%} | |||||
{% if salt['pillar.get']('network:resolver:domain') is defined %} | |||||
domain: {{ salt['pillar.get']('network:resolver:domain') }} | |||||
{%- endif -%} | |||||
{%- if salt['pillar.get']('network:resolver:search') is defined %} | |||||
search: {{ salt['pillar.get']('network:resolver:search') }} | |||||
{%- endif -%} | |||||
{%- if salt['pillar.get']('network:resolver:nameservers') is defined -%} | |||||
{%- for n in salt['pillar.get']('network:resolver:nameservers') %} | |||||
nameserver: {{ n }} | |||||
{%- endfor -%} | |||||
{%- endif -%} | |||||
{%- if salt['pillar.get']('network:resolver:options') is defined %} | |||||
options: {{ salt['pillar.get']('network:resolver:options')|join(' ') }} | |||||
{%- endif -%} | |||||
{%- if salt['pillar.get']('network:resolver:file_append') is defined %} | |||||
{{ salt['pillar.get']('network:resolver:file_append') }} | |||||
{%- endif %} |
netmask: 255.255.255.0 | netmask: 255.255.255.0 | ||||
gateway: 192.168.2.1 | gateway: 192.168.2.1 | ||||
- name: eth2 | - name: eth2 | ||||
resolver: | |||||
domain: domain.local | |||||
search: domain.local | |||||
nameservers: | |||||
- 192.168.2.1 | |||||
- 2002::beef | |||||
options: | |||||
- rotate | |||||
- timeout:1 |