Saltstack Official FirewallD Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ipsets.sls 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. # Backward compatibility setting and deprecation notices
  7. {% set ipset_manage = false %}
  8. {% set ipset_pkg = 'ipset' %}
  9. {% set ipset_sets = firewalld.ipsets %}
  10. {% if firewalld.ipset is mapping %}
  11. {% set ipset_manage = firewalld.ipset.manage %}
  12. {% set ipset_pkg = firewalld.ipset.pkg %}
  13. {% else %}
  14. ### Manage setting (old firewalld:ipset)
  15. firewalld-ipset-deprecated:
  16. test.show_notification:
  17. - text: |
  18. 'firewalld:ipset' format has changed and setting it as boolean is deprecated.
  19. Set 'firewalld:ipset:manage' instead.
  20. See firewalld/pillar.example for more information
  21. {% set ipset_manage = firewalld.ipset %}
  22. {% endif %}
  23. ### Package setting (old firewalld:ipsetpackage)
  24. {% if firewalld.ipsetpackage is defined %}
  25. firewalld-ipsetpackage-deprecated:
  26. test.show_notification:
  27. - text: |
  28. 'firewalld:ipsetpackage' is deprecated. Use 'firewalld:ipset:pkg' instead
  29. See firewalld/pillar.example for more information
  30. {% set ipset_pkg = firewalld.ipsetpackage %}
  31. {% endif %}
  32. {%- if ipset_manage %}
  33. package_ipset:
  34. pkg.installed:
  35. - name: {{ ipset_pkg }}
  36. directory_firewalld_ipsets:
  37. file.directory: # make sure this is a directory
  38. - name: /etc/firewalld/ipsets
  39. - user: root
  40. - group: root
  41. - mode: 750
  42. - require:
  43. - pkg: package_firewalld # make sure package is installed
  44. - require_in:
  45. - service: service_firewalld
  46. - watch_in:
  47. - cmd: reload_firewalld # reload firewalld config
  48. # == Define: firewalld.ipsets
  49. #
  50. # This defines a ipset configuration, see firewalld.ipset (5) man page.
  51. #
  52. {% for k, v in ipset_sets.items() %}
  53. {% set z_name = v.name|default(k) %}
  54. /etc/firewalld/ipsets/{{ z_name }}.xml:
  55. file.managed:
  56. - name: /etc/firewalld/ipsets/{{ z_name }}.xml
  57. - user: root
  58. - group: root
  59. - mode: 644
  60. - source: salt://firewalld/files/ipset.xml
  61. - template: jinja
  62. - require:
  63. - pkg: package_firewalld # make sure package is installed
  64. - file: directory_firewalld_ipsets
  65. - require_in:
  66. - service: service_firewalld
  67. - watch_in:
  68. - cmd: reload_firewalld # reload firewalld config
  69. - context:
  70. name: {{ z_name }}
  71. ipset: {{ v|json }}
  72. {% endfor %}
  73. {%- endif %}