Bläddra i källkod

simplify default/ pillar configuration

tags/v0.1
Arnold Bechtoldt 10 år sedan
förälder
incheckning
36345b081e
4 ändrade filer med 47 tillägg och 47 borttagningar
  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 Visa fil

{% load_yaml as rawmap %} {% load_yaml as rawmap %}
Debian: Debian:
interface_defaults:
enabled: True
proto: dhcp
type: eth
default_interfaces:
- name: lo
proto: loopback
interfaces:
values:
enabled: True
proto: dhcp
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
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 %} {% endload %}

+ 2
- 2
network/hosts.sls Visa fil

{% from "network/defaults.yaml" import rawmap with context %} {% from "network/defaults.yaml" import rawmap with context %}
{% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %} {% 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) %} {% if salt['pillar.get']('network:hosts', False) %}
{% set hosts = hosts + salt['pillar.get']('network:hosts') %} {% set hosts = hosts + salt['pillar.get']('network:hosts') %}
{% for h in hosts %} {% for h in hosts %}
host-{{ h['name'] }}_{{ h['ip'] }}: host-{{ h['name'] }}_{{ h['ip'] }}:
host: host:
- {{ h['ensure']|default(datamap['host_defaults']['ensure']) }}
- {{ h['ensure']|default(datamap['hosts']['values']['ensure']) }}
- ip: {{ h['ip'] }} - ip: {{ h['ip'] }}
- name: {{ h['name'] }} - name: {{ h['name'] }}
{% endfor %} {% endfor %}

+ 4
- 7
network/interfaces.sls Visa fil

{% from "network/defaults.yaml" import rawmap with context %} {% from "network/defaults.yaml" import rawmap with context %}
{% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %} {% 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) %} {% if salt['pillar.get']('network:interfaces', False) %}
{% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %} {% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %}
network: network:
- managed - managed
- name: {{ n['name'] }} - 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['proto'] in ['static'] %}
{% if n['ipaddr'] is defined %} {% if n['ipaddr'] is defined %}
- ipaddr: {{ n['ipaddr'] }} - ipaddr: {{ n['ipaddr'] }}
{% if n['netmask'] is defined %} {% if n['netmask'] is defined %}
- netmask: {{ n['netmask'] }} - netmask: {{ n['netmask'] }}
{% endif %} {% endif %}
{% if n['broadcast'] is defined %}
- broadcast: {{ n['broadcast'] }}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}

+ 1
- 1
network/resolver.sls Visa fil

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

Laddar…
Avbryt
Spara