Bechtoldt's Network Saltstack Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

interfaces.sls 1.1KB

1234567891011121314151617181920212223242526272829303132
  1. {% from "network/defaults.yaml" import rawmap with context %}
  2. {% set datamap = salt['grains.filter_by'](rawmap, merge=salt['pillar.get']('network:lookup')) %}
  3. {% set interfaces = datamap['default_interfaces'] %}
  4. {% if salt['pillar.get']('network:interfaces') is defined %}
  5. {% set interfaces = interfaces + salt['pillar.get']('network:interfaces') %}
  6. {% endif %}
  7. {% for n in interfaces %}
  8. network-{{ n['name'] }}:
  9. network:
  10. - managed
  11. - name: {{ n['name'] }}
  12. - enabled: {{ n['enabled']|default(datamap['interface_defaults']['enabled']) }}
  13. - proto: {{ n['proto']|default(datamap['interface_defaults']['proto']) }}
  14. - type: {{ n['type']|default(datamap['interface_defaults']['type']) }}
  15. {% if n['proto'] in ['static'] %}
  16. {% if n['ipaddr'] is defined %}
  17. - ipaddr: {{ n['ipaddr'] }}
  18. {% endif %}
  19. {% if n['gateway'] is defined %}
  20. - gateway: {{ n['gateway'] }}
  21. {% endif %}
  22. {% if n['netmask'] is defined %}
  23. - netmask: {{ n['netmask'] }}
  24. {% endif %}
  25. {% if n['broadcast'] is defined %}
  26. - broadcast: {{ n['broadcast'] }}
  27. {% endif %}
  28. {% endif %}
  29. {% endfor %}