Bechtoldt's Network Saltstack Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

60 lines
1.7KB

  1. #!jinja|yaml
  2. {% from "network/defaults.yaml" import rawmap with context %}
  3. {% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %}
  4. {% set interfaces = datamap.interfaces.def_entries %}
  5. {% set pkgs = datamap.interfaces.pkgs|default([]) %}
  6. {%- macro set_p(paramname, dictvar) -%}
  7. {%- if paramname in dictvar -%}
  8. - {{ paramname }}: {{ dictvar[paramname] }}
  9. {%- endif -%}
  10. {%- endmacro -%}
  11. {% if salt['pillar.get']('network:interfaces', False) %}
  12. {% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %}
  13. {% endif %}
  14. {% for n in interfaces %}
  15. network_{{ n.name }}:
  16. network:
  17. - managed
  18. - name: {{ n.name }}
  19. - enabled: {{ n.enabled|default(datamap.interfaces.default_values.enabled) }}
  20. - type: {{ n.type|default(datamap.interfaces.default_values.type) }}
  21. {% for p in datamap.interfaces.params_supported %}
  22. {{ set_p(p, n) }}
  23. {% endfor %}
  24. {% if n.use is defined %}
  25. - use:
  26. {% for u in n.use %}
  27. - network: network_{{ u }}
  28. {% endfor %}
  29. {% endif %}
  30. {% if n.provider is defined %}
  31. - provider: {{ n.provider }}
  32. {% endif %}
  33. {% if n.user is defined %}
  34. - user: {{ n.user }}
  35. {% endif %}
  36. {% if n.password is defined %}
  37. - password: {{ n.password }}
  38. {% endif %}
  39. {% if n.pppoe_iface is defined %}
  40. - pppoe_iface: {{ n.pppoe_iface }}
  41. {% endif %}
  42. {% if n.type|default(datamap.interfaces.default_values.type) == 'vlan' and datamap.interfaces.vlan_pkg|default('vlan') %}
  43. {% do pkgs.append(datamap.interfaces.vlan_pkg|default('vlan')) %}
  44. - require:
  45. - pkg: packages
  46. {% endif %}
  47. {% endfor %}
  48. {% if pkgs|length > 0 %}
  49. packages:
  50. pkg:
  51. - installed
  52. - pkgs: {{ pkgs }}
  53. {% endif %}