Browse Source

improving installation of the optional vlan package. this change should work for Debian and Redhat family. If you are using a Redhat based os, load your needed kernel modules with https://github.com/bechtoldt/linux-formula

tags/v0.1
Arnold Bechtoldt 10 years ago
parent
commit
91e8a0e647
2 changed files with 17 additions and 14 deletions
  1. +3
    -0
      network/defaults.yaml
  2. +14
    -14
      network/interfaces.sls

+ 3
- 0
network/defaults.yaml View File

{% load_yaml as rawmap %} {% load_yaml as rawmap %}
Debian: Debian:
interfaces: interfaces:
pkgs: []
default_values: default_values:
enable: True enable: True
proto: dhcp proto: dhcp
ip: 127.0.1.1 ip: 127.0.1.1
RedHat: RedHat:
interfaces: interfaces:
pkgs: []
vlan_pkg: False
values: values:
enable: True enable: True
proto: dhcp proto: dhcp

+ 14
- 14
network/interfaces.sls View File

{% 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.interfaces.def_entries %} {% set interfaces = datamap.interfaces.def_entries %}
{% set pkgs = datamap.interfaces.pkgs|default([]) %}


{%- macro set_p(paramname, dictvar) -%} {%- macro set_p(paramname, dictvar) -%}
{%- if paramname in dictvar -%} {%- if paramname in dictvar -%}
{% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %} {% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %}
{% endif %} {% endif %}


{# http://stackoverflow.com/questions/4870346/can-a-jinja-variables-scope-extend-beyond-in-an-inner-block #}
{%- set vlanRequired = [] -%}

{% for n in interfaces %} {% for n in interfaces %}
network-{{ n.name }}: network-{{ n.name }}:
network: network:
- enabled: {{ n.enable|default(datamap.interfaces.default_values.enable) }} - enabled: {{ n.enable|default(datamap.interfaces.default_values.enable) }}
- proto: {{ n.proto|default(datamap.interfaces.default_values.proto) }} - proto: {{ n.proto|default(datamap.interfaces.default_values.proto) }}
- type: {{ n.type|default(datamap.interfaces.default_values.type) }} - type: {{ n.type|default(datamap.interfaces.default_values.type) }}
{% for p in datamap.interfaces.params_supported %}
{% for p in datamap.interfaces.params_supported %}
{{ set_p(p, n) }} {{ set_p(p, n) }}
{% endfor %}
{% if n.use is defined %}
{% endfor %}
{% if n.use is defined %}
- use: - use:
{% for u in n.use %} {% for u in n.use %}
- network: network-{{ u }} - network: network-{{ u }}
{% endfor %} {% endfor %}
{% endif %}
{% if n.type == 'vlan' %}
{% do vlanRequired.append(1) -%}
{% endif %}
{% if n.type|default(datamap.interfaces.default_values.type) == 'vlan' and datamap.interfaces.vlan_pkg|default('vlan') %}
{% do pkgs.append(datamap.interfaces.vlan_pkg|default('vlan')) %}
- require: - require:
- pkg: vlan
{% endif %}
- pkg: packages
{% endif %}
{% endfor %} {% endfor %}


{% if vlanRequired %}
vlan:
pkg.installed
{% if pkgs|length > 0 %}
packages:
pkg:
- installed
- pkgs: {{ pkgs }}
{% endif %} {% endif %}

Loading…
Cancel
Save