Browse Source

adding hosts configuration

tags/v0.1
Arnold Bechtoldt 10 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



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

+ 30
- 2
network/defaults.yaml View File

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

+ 16
- 0
network/hosts.sls View File

{% 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

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

+ 9
- 0
pillar.example.sls View File

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

Loading…
Cancel
Save