Bladeren bron

simplify default/ pillar configuration

tags/v0.1
Arnold Bechtoldt 10 jaren geleden
bovenliggende
commit
36345b081e
4 gewijzigde bestanden met toevoegingen van 47 en 47 verwijderingen
  1. +40
    -37
      network/defaults.yaml
  2. +2
    -2
      network/hosts.sls
  3. +4
    -7
      network/interfaces.sls
  4. +1
    -1
      network/resolver.sls

+ 40
- 37
network/defaults.yaml Bestand weergeven

@@ -1,41 +1,44 @@
{% load_yaml as rawmap %}
Debian:
interface_defaults:
enabled: True
proto: dhcp
type: eth
default_interfaces:
- name: lo
proto: loopback
interfaces:
values:
enabled: True
proto: dhcp
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
def_entries:
- name: lo
proto: loopback
type: eth
resolver:
values:
path: /etc/resolv.conf
hosts:
values:
path: /etc/hosts
ensure: present
def_entries:
- 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 %}

+ 2
- 2
network/hosts.sls Bestand weergeven

@@ -1,7 +1,7 @@
{% 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'] %}
{% set hosts = datamap['hosts']['def_entries'] %}

{% if salt['pillar.get']('network:hosts', False) %}
{% set hosts = hosts + salt['pillar.get']('network:hosts') %}
@@ -10,7 +10,7 @@
{% for h in hosts %}
host-{{ h['name'] }}_{{ h['ip'] }}:
host:
- {{ h['ensure']|default(datamap['host_defaults']['ensure']) }}
- {{ h['ensure']|default(datamap['hosts']['values']['ensure']) }}
- ip: {{ h['ip'] }}
- name: {{ h['name'] }}
{% endfor %}

+ 4
- 7
network/interfaces.sls Bestand weergeven

@@ -1,7 +1,7 @@
{% from "network/defaults.yaml" import rawmap with context %}
{% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %}

{% set interfaces = datamap['default_interfaces'] %}
{% set interfaces = datamap['interfaces']['def_entries'] %}

{% if salt['pillar.get']('network:interfaces', False) %}
{% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %}
@@ -12,9 +12,9 @@ network-{{ n['name'] }}:
network:
- managed
- name: {{ n['name'] }}
- enabled: {{ n['enabled']|default(datamap['interface_defaults']['enabled']) }}
- proto: {{ n['proto']|default(datamap['interface_defaults']['proto']) }}
- type: {{ n['type']|default(datamap['interface_defaults']['type']) }}
- enabled: {{ n['enabled']|default(datamap['interfaces']['values']['enabled']) }}
- proto: {{ n['proto']|default(datamap['interfaces']['values']['proto']) }}
- type: {{ n['type']|default(datamap['interfaces']['values']['type']) }}
{% if n['proto'] in ['static'] %}
{% if n['ipaddr'] is defined %}
- ipaddr: {{ n['ipaddr'] }}
@@ -25,8 +25,5 @@ network-{{ n['name'] }}:
{% if n['netmask'] is defined %}
- netmask: {{ n['netmask'] }}
{% endif %}
{% if n['broadcast'] is defined %}
- broadcast: {{ n['broadcast'] }}
{% endif %}
{% endif %}
{% endfor %}

+ 1
- 1
network/resolver.sls Bestand weergeven

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

Laden…
Annuleren
Opslaan