Browse Source

adding hosts configuration

tags/v0.1
Arnold Bechtoldt 11 years ago
parent
commit
74c2e2f85e
5 changed files with 60 additions and 3 deletions
  1. +4
    -0
      README.md
  2. +30
    -2
      network/defaults.yaml
  3. +16
    -0
      network/hosts.sls
  4. +1
    -1
      network/resolver.sls
  5. +9
    -0
      pillar.example.sls

+ 4
- 0
README.md View File

@@ -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

+ 30
- 2
network/defaults.yaml View File

@@ -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 %}

+ 16
- 0
network/hosts.sls View File

@@ -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 %}

+ 1
- 1
network/resolver.sls View File

@@ -4,7 +4,7 @@
resolver:
file:
- managed
- name: {{ datamap['resolver']['path'] }}
- name: {{ datamap['resolver_defaults']['path'] }}
- mode: '0644'
- user: root
- group: root

+ 9
- 0
pillar.example.sls View File

@@ -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

Loading…
Cancel
Save