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.

123456789101112131415161718192021222324252627282930313233
  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. resolver:
  5. file:
  6. - managed
  7. - name: {{ datamap.resolver.path|default('/etc/resolv.conf') }}
  8. - user: {{ datamap.resolver.user|default('root') }}
  9. - group: {{ datamap.resolver.group|default('root') }}
  10. - mode: {{ datamap.resolver.mode|default(644) }}
  11. - contents: |
  12. {%- if salt['pillar.get']('network:resolver:file_prepend', False) %}
  13. {{ salt['pillar.get']('network:resolver:file_prepend') }}
  14. {%- endif -%}
  15. {% if salt['pillar.get']('network:resolver:domain', False) %}
  16. domain {{ salt['pillar.get']('network:resolver:domain') }}
  17. {%- endif -%}
  18. {%- if salt['pillar.get']('network:resolver:search', False) %}
  19. search {{ salt['pillar.get']('network:resolver:search')|join(' ') }}
  20. {%- endif -%}
  21. {%- if salt['pillar.get']('network:resolver:nameservers', False) -%}
  22. {%- for n in salt['pillar.get']('network:resolver:nameservers') %}
  23. nameserver {{ n }}
  24. {%- endfor -%}
  25. {%- endif -%}
  26. {%- if salt['pillar.get']('network:resolver:options', False) %}
  27. options {{ salt['pillar.get']('network:resolver:options')|sort|join(' ') }}
  28. {%- endif -%}
  29. {%- if salt['pillar.get']('network:resolver:file_append', False) %}
  30. {{ salt['pillar.get']('network:resolver:file_append') }}
  31. {%- endif %}