瀏覽代碼

Refactor backend format, add backward compatibility, simple pkg testing

See https://github.com/saltstack-formulas/firewalld-formula/pull/21#pullrequestreview-146958098
tags/v0.6.2
Javier Bértoli 6 年之前
父節點
當前提交
15a48462f0
共有 6 個檔案被更改,包括 53 行新增5 行删除
  1. +28
    -2
      firewalld/backend.sls
  2. +2
    -2
      firewalld/defaults.yaml
  3. +2
    -1
      pillar.example
  4. +3
    -0
      test/integration/default/backend_spec.rb
  5. +15
    -0
      test/integration/default/firewalld_spec.rb
  6. +3
    -0
      test/integration/default/ipset_spec.rb

+ 28
- 2
firewalld/backend.sls 查看文件

@@ -4,8 +4,34 @@
#
{% 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:
pkg.installed:
- name: {{ firewalld.backendpackage }}
- name: {{ backend_pkg }}
{%- endif %}

+ 2
- 2
firewalld/defaults.yaml 查看文件

@@ -7,11 +7,11 @@ firewalld:
config: /etc/firewalld.conf

ipset:
manage: true
manage: false
pkg: ipset

backend:
manage: true
manage: false
pkg: nftables

ipsets: {}

+ 2
- 1
pillar.example 查看文件

@@ -5,7 +5,8 @@ firewalld:
manage: True
pkg: ipset

installbackend: False
installbackend: True
backendpackage: nftables
default_zone: public

services:

+ 3
- 0
test/integration/default/backend_spec.rb 查看文件

@@ -0,0 +1,3 @@
describe package('nftables') do
it { should be_installed }
end

+ 15
- 0
test/integration/default/firewalld_spec.rb 查看文件

@@ -1,3 +1,18 @@
describe package('firewalld') do
it { should be_installed }
end

describe service('firewalld') do
it { should be_enabled }
it { should be_running }
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 查看文件

@@ -0,0 +1,3 @@
describe package('ipset') do
it { should be_installed }
end

Loading…
取消
儲存