|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #!jinja|yaml
-
- {% from "network/defaults.yaml" import rawmap with context %}
- {% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %}
-
- {% set interfaces = datamap.interfaces.def_entries %}
- {% set pkgs = datamap.interfaces.pkgs|default([]) %}
-
- {%- macro set_p(paramname, dictvar) -%}
- {%- if paramname in dictvar -%}
- - {{ paramname }}: {{ dictvar[paramname] }}
- {%- endif -%}
- {%- endmacro -%}
-
- {%- if 'dhclient_conf' in salt['pillar.get']('network') %}
- dhclient_conf:
- file.managed:
- - name: /etc/dhcp/dhclient.conf
- - mode: 644
- - user: root
- - group: root
- - contents_pillar: network:dhclient_conf
- {% endif %}
-
- {%- if salt['pillar.get']('network:interfaces', False) %}
- {% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %}
- {% endif %}
-
- {% for n in interfaces -%}
- {%- if 'ipaddr' in n -%}
- {%- set state_id = 'network_' ~ n.name ~ '_' ~ n.ipaddr -%}
- {%- else %}
- {%- set state_id = 'network_' ~ n.name -%}
- {%- endif %}
-
- {{ state_id }}:
- network:
- - managed
- - name: {{ n.name }}
- - enabled: {{ n.enabled|default(datamap.interfaces.default_values.enabled) }}
- - type: {{ n.type|default(datamap.interfaces.default_values.type) }}
- {% for p in datamap.interfaces.params_supported %}
- {{ set_p(p, n) }}
- {% endfor %}
- {% if n.use is defined %}
- - use:
- {% for u in n.use %}
- - network: network_{{ u }}
- {% endfor %}
- {% endif %}
- {% if n.provider is defined %}
- - provider: {{ n.provider }}
- {% endif %}
- {% if n.user is defined %}
- - user: {{ n.user }}
- {% endif %}
- {% if n.password is defined %}
- - password: {{ n.password }}
- {% endif %}
- {% if n.pppoe_iface is defined %}
- - pppoe_iface: {{ n.pppoe_iface }}
- {% 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:
- - pkg: packages
- {% endif %}
- {% endfor %}
-
- {% if pkgs|length > 0 %}
- packages:
- pkg:
- - installed
- - pkgs: {{ pkgs }}
- {% endif %}
|