Saltstack Official FirewallD 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.

49 line
1.3KB

  1. # == State: firewalld.ipsets
  2. #
  3. # This state ensures that /etc/firewalld/ipsets/ exists.
  4. #
  5. {% from "firewalld/map.jinja" import firewalld with context %}
  6. {%- if salt['pillar.get']('firewalld:ipset') %}
  7. package_ipset:
  8. pkg.installed:
  9. - name: {{ firewalld.ipsetpackage }}
  10. directory_firewalld_ipsets:
  11. file.directory: # make sure this is a directory
  12. - name: /etc/firewalld/ipsets
  13. - user: root
  14. - group: root
  15. - mode: 750
  16. - require:
  17. - pkg: package_firewalld # make sure package is installed
  18. - listen_in:
  19. - module: service_firewalld # restart service
  20. # == Define: firewalld.ipsets
  21. #
  22. # This defines a ipset configuration, see firewalld.ipset (5) man page.
  23. #
  24. {% for k, v in salt['pillar.get']('firewalld:ipsets', {}).items() %}
  25. {% set z_name = v.name|default(k) %}
  26. /etc/firewalld/ipsets/{{ z_name }}.xml:
  27. file.managed:
  28. - name: /etc/firewalld/ipsets/{{ z_name }}.xml
  29. - user: root
  30. - group: root
  31. - mode: 644
  32. - source: salt://firewalld/files/ipset.xml
  33. - template: jinja
  34. - require:
  35. - pkg: package_firewalld # make sure package is installed
  36. - file: directory_firewalld_ipsets
  37. - listen_in:
  38. - module: service_firewalld # restart service
  39. - context:
  40. name: {{ z_name }}
  41. ipset: {{ v }}
  42. {% endfor %}
  43. {%- endif %}