Kaynağa Gözat

adding resolver config

tags/v0.1
Arnold Bechtoldt 10 yıl önce
ebeveyn
işleme
4ffff2d7c9
5 değiştirilmiş dosya ile 54 ekleme ve 8 silme
  1. +8
    -4
      README.md
  2. +3
    -1
      network/defaults.yaml
  3. +3
    -3
      network/interfaces.sls
  4. +31
    -0
      network/resolver.sls
  5. +9
    -0
      pillar.example.sls

+ 8
- 4
README.md Dosyayı Görüntüle

@@ -8,7 +8,7 @@ Salt Stack Formula to set up and configure a host's network configuration

## TODO

None
* Use more of the available options in interfaces.sls of network.managed

## Instructions

@@ -20,9 +20,13 @@ None

## Available states

### network
### network.interfaces

Sets the network interfaces configuration

### network.resolver

\#TODO
Sets the resolver configuration

## Additional resources

@@ -36,4 +40,4 @@ None

*DOES* work on:

* GNU/ Linux Debian Wheezy
* GNU/ Linux Debian Wheezy (Salt: 2014.1.0)

+ 3
- 1
network/defaults.yaml Dosyayı Görüntüle

@@ -1,9 +1,11 @@
{% load_yaml as rawmap %}
Debian:
defaults:
interface_defaults:
enabled: True
proto: dhcp
type: eth
resolver:
path: /etc/resolv.conf
default_interfaces:
- name: lo
proto: loopback

network/init.sls → network/interfaces.sls Dosyayı Görüntüle

@@ -12,9 +12,9 @@ network-{{ n['name'] }}:
network:
- managed
- 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['ipaddr'] is defined %}
- ipaddr: {{ n['ipaddr'] }}

+ 31
- 0
network/resolver.sls Dosyayı Görüntüle

@@ -0,0 +1,31 @@
{% 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 %}

+ 9
- 0
pillar.example.sls Dosyayı Görüntüle

@@ -9,3 +9,12 @@ network:
netmask: 255.255.255.0
gateway: 192.168.2.1
- name: eth2
resolver:
domain: domain.local
search: domain.local
nameservers:
- 192.168.2.1
- 2002::beef
options:
- rotate
- timeout:1

Yükleniyor…
İptal
Kaydet