Przeglądaj źródła

Merge pull request #23 from netmanagers/master

Refactor ipset & backend
tags/v0.6.2
Niels Abspoel 6 lat temu
rodzic
commit
a2d99c5957
Brak konta powiązanego z adresem e-mail autora
10 zmienionych plików z 115 dodań i 25 usunięć
  1. +2
    -11
      .kitchen.yml
  2. +1
    -1
      VERSION
  3. +28
    -2
      firewalld/backend.sls
  4. +11
    -2
      firewalld/defaults.yaml
  5. +1
    -1
      firewalld/init.sls
  6. +36
    -5
      firewalld/ipsets.sls
  7. +15
    -3
      pillar.example
  8. +3
    -0
      test/integration/default/backend_spec.rb
  9. +15
    -0
      test/integration/default/firewalld_spec.rb
  10. +3
    -0
      test/integration/default/ipset_spec.rb

+ 2
- 11
.kitchen.yml Wyświetl plik

salt_copy_filter: salt_copy_filter:
- .kitchen - .kitchen
- .git - .git
pillars-from-files:
firewalld.sls: pillar.example
pillars: pillars:
top.sls: top.sls:
base: base:
'*': '*':
- firewalld - firewalld
firewalld.sls:
firewalld:
enabled: True
services:
glusterfs:
short: glusterfs
description: 'GlusterFS network filesystem'
ports:
tcp:
- 24007-24008
- 49152-49200


verifier: verifier:
name: inspec name: inspec

+ 1
- 1
VERSION Wyświetl plik

0.2.0
0.2.1

+ 28
- 2
firewalld/backend.sls Wyświetl plik

# #
{% from "firewalld/map.jinja" import firewalld with context %} {% from "firewalld/map.jinja" import firewalld with context %}


{%- if salt['pillar.get']('firewalld:installbackend') %}
{% set backend_manage = firewalld.backend.manage %}
{% set backend_pkg = firewalld.backend.pkg %}

# Backward compatibility setting and deprecation notices
### Manage setting (old firewalld:installbackend)
{% if firewalld.installbackend is defined %}
firewalld-installbackend-deprecated:
test.show_notification:
- text: |
'firewalld:installbackend' is deprecated. Set 'firewalld:backend:manage' instead.
See firewalld/pillar.example for more information

{% set backend_manage = firewalld.installbackend %}
{% endif %}

### Package setting (old firewalld:backendpackage)
{% if firewalld.backendpackage is defined %}
firewalld-backendpackage-deprecated:
test.show_notification:
- text: |
'firewalld:backendpackage' is deprecated. Use 'firewalld:backend:pkg' instead
See firewalld/pillar.example for more information

{% set backend_pkg = firewalld.backendpackage %}
{% endif %}

{%- if backend_manage %}
package_backend: package_backend:
pkg.installed: pkg.installed:
- name: {{ firewalld.backendpackage }}
- name: {{ backend_pkg }}
{%- endif %} {%- endif %}

+ 11
- 2
firewalld/defaults.yaml Wyświetl plik

# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: ft=yaml # vim: ft=yaml
firewalld: firewalld:
enabled: true
package: firewalld package: firewalld
ipsetpackage: ipset
backendpackage: nftables
service: firewalld service: firewalld
config: /etc/firewalld.conf config: /etc/firewalld.conf

ipset:
manage: false
pkg: ipset

backend:
manage: false
pkg: nftables

ipsets: {}

+ 1
- 1
firewalld/init.sls Wyświetl plik

Firewalld is not supported on {{ grains['osfinger'] }} Firewalld is not supported on {{ grains['osfinger'] }}
See https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-323460 See https://www.suse.com/releasenotes/x86_64/SUSE-SLES/15/#fate-323460


{% elif salt['pillar.get']('firewalld:enabled') %}
{% elif firewalld.enabled %}


include: include:
- firewalld.config - firewalld.config

+ 36
- 5
firewalld/ipsets.sls Wyświetl plik

# #
{% from "firewalld/map.jinja" import firewalld with context %} {% from "firewalld/map.jinja" import firewalld with context %}


{%- if salt['pillar.get']('firewalld:ipset') %}
# Backward compatibility setting and deprecation notices
{% set ipset_manage = false %}
{% set ipset_pkg = 'ipset' %}
{% set ipset_sets = firewalld.ipsets %}

{% if firewalld.ipset is mapping %}
{% set ipset_manage = firewalld.ipset.manage %}
{% set ipset_pkg = firewalld.ipset.pkg %}
{% else %}
### Manage setting (old firewalld:ipset)
firewalld-ipset-deprecated:
test.show_notification:
- text: |
'firewalld:ipset' format has changed and setting it as boolean is deprecated.
Set 'firewalld:ipset:manage' instead.
See firewalld/pillar.example for more information

{% set ipset_manage = firewalld.ipset %}
{% endif %}

### Package setting (old firewalld:ipsetpackage)
{% if firewalld.ipsetpackage is defined %}
firewalld-ipsetpackage-deprecated:
test.show_notification:
- text: |
'firewalld:ipsetpackage' is deprecated. Use 'firewalld:ipset:pkg' instead
See firewalld/pillar.example for more information

{% set ipset_pkg = firewalld.ipsetpackage %}
{% endif %}

{%- if ipset_manage %}
package_ipset: package_ipset:
pkg.installed: pkg.installed:
- name: {{ firewalld.ipsetpackage }}
- name: {{ ipset_pkg }}


directory_firewalld_ipsets: directory_firewalld_ipsets:
file.directory: # make sure this is a directory file.directory: # make sure this is a directory
# #
# This defines a ipset configuration, see firewalld.ipset (5) man page. # This defines a ipset configuration, see firewalld.ipset (5) man page.
# #
{% for k, v in salt['pillar.get']('firewalld:ipsets', {}).items() %}
{% set z_name = v.name|default(k) %}
{% for k, v in ipset_sets.items() %}
{% set z_name = v.name|default(k) %}


/etc/firewalld/ipsets/{{ z_name }}.xml: /etc/firewalld/ipsets/{{ z_name }}.xml:
file.managed: file.managed:
name: {{ z_name }} name: {{ z_name }}
ipset: {{ v }} ipset: {{ v }}


{% endfor %}
{% endfor %}
{%- endif %} {%- endif %}

+ 15
- 3
pillar.example Wyświetl plik

# FirewallD pillar examples: # FirewallD pillar examples:
firewalld: firewalld:
enabled: True enabled: True
ipset: True
installbackend: False

ipset:
manage: True
pkg: ipset

# ipset: # Deprecated. Support for this format will be removed in future releases
# ipsetpackag: ipset # Deprecated. Will be removed in future releases

backend:
manage: True
pkg: nftables

# installbackend: True # Deprecated. Will be removed in future releases
# backendpackage: nftables # Deprecated. Will be removed in future releases

default_zone: public default_zone: public


services: services:
entries: entries:
- 10.0.0.1 - 10.0.0.1



zones: zones:
public: public:
short: Public short: Public

+ 3
- 0
test/integration/default/backend_spec.rb Wyświetl plik

describe package('nftables') do
it { should be_installed }
end

+ 15
- 0
test/integration/default/firewalld_spec.rb Wyświetl plik

describe package('firewalld') do
it { should be_installed }
end

describe service('firewalld') do describe service('firewalld') do
it { should be_enabled }
it { should be_running } it { should be_running }
end end

describe service('iptables') do
it { should_not be_enabled }
it { should_not be_running }
end

describe service('ip6tables') do
it { should_not be_enabled }
it { should_not be_running }
end

+ 3
- 0
test/integration/default/ipset_spec.rb Wyświetl plik

describe package('ipset') do
it { should be_installed }
end

Ładowanie…
Anuluj
Zapisz