diff --git a/.travis.yml b/.travis.yml index d16c765..3b35364 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ --- stages: - test - - commitlint + - lint - name: release if: branch = master AND type != pull_request @@ -65,16 +65,21 @@ script: jobs: include: - # Define the commitlint stage - - stage: commitlint + # Define the `lint` stage (runs `yamllint` and `commitlint`) + - stage: lint language: node_js node_js: lts/* before_install: skip script: + # Install and run `yamllint` + - pip install --user yamllint + # yamllint disable-line rule:line-length + - yamllint -s . .yamllint pillar.example test/salt/pillar/default.pillar.sls test/salt/pillar/tables.pillar.sls + # Install and run `commitlint` - npm install @commitlint/config-conventional -D - npm install @commitlint/travis-cli -D - commitlint-travis - # Define the release stage that runs semantic-release + # Define the release stage that runs `semantic-release` - stage: release language: node_js node_js: lts/* diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..8c99021 --- /dev/null +++ b/.yamllint @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- +# Extend the `default` configuration provided by `yamllint` +extends: default + +# Files to ignore completely +# 1. All YAML files under directory `node_modules/`, introduced during the Travis run +ignore: | + node_modules/ + +rules: + key-duplicates: + ignore: | + pillar.example + line-length: + # Increase from default of `80` + # Based on https://github.com/PyCQA/flake8-bugbear#opinionated-warnings (`B950`) + max: 88 diff --git a/iptables/defaults.yaml b/iptables/defaults.yaml index f8ab1ba..d439d85 100644 --- a/iptables/defaults.yaml +++ b/iptables/defaults.yaml @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # vim: ft=yaml +--- firewall: enabled: false install: false @@ -47,4 +48,3 @@ firewall: POSTROUTING: policy: ACCEPT rules: {} - diff --git a/iptables/osfamilymap.yaml b/iptables/osfamilymap.yaml index d54f418..18a7c81 100644 --- a/iptables/osfamilymap.yaml +++ b/iptables/osfamilymap.yaml @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # vim: ft=yaml +--- Debian: pkgs: - iptables diff --git a/pillar.example b/pillar.example index efef828..25276c5 100644 --- a/pillar.example +++ b/pillar.example @@ -1,22 +1,25 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- firewall: - install: True - enabled: True - strict: True - ipv6: True + install: true + enabled: true + strict: true + ipv6: true services: ssh: - block_nomatch: True + block_nomatch: true ips_allow: - 10.0.0.0/8 - 172.16.0.0/12 - 192.168.0.0/16 http: - block_nomatch: False + block_nomatch: false protos: - udp - tcp snmp: - block_nomatch: False + block_nomatch: false protos: - udp - tcp @@ -25,17 +28,17 @@ firewall: services_ipv6: ssh: - block_nomatch: False + block_nomatch: false ips_allow: - 2a02:2028:773:d01:10a5:f34f:e7ff:f55b/64 - 2a02:2028:773:d01:1814:28ef:e91b:70b8/64 http: - block_nomatch: False + block_nomatch: false protos: - udp - tcp snmp: - block_nomatch: False + block_nomatch: false protos: - udp - tcp @@ -52,9 +55,11 @@ firewall: ips_allow: - 2a02:2028:773:d01:1814:28ef:e91b:70b8/64 - #Support nat (ipv4 only) + # yamllint disable rule:line-length + # Support nat (ipv4 only) # iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 10.20.0.2 -j MASQUERADE # iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 172.31.0.2 -j MASQUERADE + # yamllint enable rule:line-length nat: eth0: rules: @@ -64,14 +69,14 @@ firewall: ### Using the tables.sls state # In this example we iterate over tables (filter, nat, mangle) and -# adds the desired entries +# adds the desired entries firewall: - install: True - enabled: True - strict: True + install: true + enabled: true + strict: true # To use tables, leave services undefined and set this to true - use_tables: True + use_tables: true filter: INPUT: diff --git a/test/integration/default/inspec.yml b/test/integration/default/inspec.yml index e992527..fc132f0 100644 --- a/test/integration/default/inspec.yml +++ b/test/integration/default/inspec.yml @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- name: default title: iptables formula maintainer: SaltStack Formulas diff --git a/test/integration/tables/inspec.yml b/test/integration/tables/inspec.yml index d3cdb9b..45f5f52 100644 --- a/test/integration/tables/inspec.yml +++ b/test/integration/tables/inspec.yml @@ -1,7 +1,11 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- name: tables title: iptables formula maintainer: SaltStack Formulas license: Apache-2.0 +# yamllint disable-line rule:line-length summary: Verify that iptables is installed and configured using tables defined in pillars supports: - platform-name: debian diff --git a/test/salt/pillar/default.pillar.sls b/test/salt/pillar/default.pillar.sls index 1d8edd8..6220200 100644 --- a/test/salt/pillar/default.pillar.sls +++ b/test/salt/pillar/default.pillar.sls @@ -1,24 +1,27 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- firewall: - install: True - enabled: True - strict: True - ipv6: False + install: true + enabled: true + strict: true + ipv6: false ## To manage the firewall writing rules instead of services, check ## the `pillar.tables.example` for examples services: ssh: - block_nomatch: True + block_nomatch: true ips_allow: - 10.0.0.0/8 - 172.16.0.0/12 - 192.168.0.0/16 http: - block_nomatch: False + block_nomatch: false protos: - udp - tcp snmp: - block_nomatch: False + block_nomatch: false protos: - udp - tcp @@ -30,9 +33,11 @@ firewall: ips_allow: - 10.0.0.0/8 - #Support nat (ipv4 only) + # yamllint disable rule:line-length + # Support nat (ipv4 only) # iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 10.20.0.2 -j MASQUERADE # iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 172.31.0.2 -j MASQUERADE + # yamllint enable rule:line-length nat: eth0: rules: diff --git a/test/salt/pillar/tables.pillar.sls b/test/salt/pillar/tables.pillar.sls index 8b08838..7ce8724 100644 --- a/test/salt/pillar/tables.pillar.sls +++ b/test/salt/pillar/tables.pillar.sls @@ -1,12 +1,15 @@ +# -*- coding: utf-8 -*- +# vim: ft=yaml +--- # In this example we iterate over tables (filter, nat, mangle) and -# adds the desired entries +# adds the desired entries firewall: - install: True - enabled: True - strict: True + install: true + enabled: true + strict: true # To use tables, leave services undefined and set this to true - use_tables: True + use_tables: true whitelist: networks: @@ -34,9 +37,11 @@ firewall: dport: 2222 jump: REJECT - #Suppport nat + # yamllint disable rule:line-length + # Suppport nat # iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 10.20.0.2 -j MASQUERADE # iptables -t nat -A POSTROUTING -o eth0 -s 192.168.18.0/24 -d 172.31.0.2 -j MASQUERADE + # yamllint enable rule:line-length nat: POSTROUTING: rules: