Bechtoldt's Network Saltstack Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

33 行
1.1KB

  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 %}