Compare commits

..

No commits in common. "bac335be1185b947458ef458361f054477aa537d" and "adc627ebc0ec66e93b2f26ccfbcd03d5e992e120" have entirely different histories.

14 changed files with 19 additions and 256 deletions

View File

@ -1,4 +0,0 @@
skip_list:
- command-instead-of-module
- no-changed-when
- role-name

View File

@ -1,23 +1,20 @@
--- ---
name: ipr-cnrs.nftables.molecule name: Molecule
on: on:
push: push:
branches: [master] branches: [main]
pull_request: pull_request:
branches: [master] branches: [main]
workflow_dispatch: workflow_dispatch:
jobs: jobs:
test: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2
- name: checkout - name: Ansible Molecule
uses: actions/checkout@v2 uses: MonolithProjects/action-molecule@v1.4.3
with:
path: "${{ github.repository }}"
- name: molecule
uses: robertdebock/molecule-action@2.6.17

View File

@ -4,8 +4,6 @@ dependencies: []
galaxy_info: galaxy_info:
author: "Jérémy Gardais" author: "Jérémy Gardais"
namespace: ipr-cnrs
role_name: nftables
description: "Manage Nftables rules and packages" description: "Manage Nftables rules and packages"
license: WTFPL license: WTFPL
company: IPR company: IPR

View File

@ -1,7 +0,0 @@
FROM archlinux:latest
ENV container=docker
RUN pacman -Sy --noconfirm python
VOLUME ["/sys/fs/cgroup", "/tmp", "/run"]
CMD ["/usr/sbin/init"]

View File

@ -1,9 +0,0 @@
---
- name: Converge
hosts: all
gather_facts: yes
roles:
- role: ipr-cnrs.nftables
nft_debug: true
# can't remove iptables on an instance with docker
nft_old_pkg_manage: false

View File

@ -1,19 +0,0 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: archlinux
image: archlinux:latest
command: /usr/sbin/init
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /run
- /tmp
provisioner:
name: ansible
verifier:
name: ansible

View File

@ -1,72 +0,0 @@
---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: check for nftables.d
stat:
path: /etc/nftables.d
register: p
- name: check nftables.d
assert:
that:
- p.stat.exists and p.stat.isdir
- name: check for nftables.conf
stat:
path: /etc/nftables.conf
register: p
- name: check nftables.conf
assert:
that:
- p.stat.exists
- name: check for nftables.conf
stat:
path: /etc/nftables.d/filter-input.nft
register: p
- name: check filter-input.nft
assert:
that:
- p.stat.exists
- name: list rules
command: nft list ruleset
register: nft
- name: debug rules
debug: var=nft
- name: check rules
assert:
that:
# The whole line is:
# type filter hook input priority 0; policy drop;
# However on CentOS will return "priority 0", while Debian will
# show "priority filter"
- '"type filter hook input" in nft.stdout'
- '"type filter hook output" in nft.stdout'
- name: service status - active
command: systemctl is-active nftables.service
register: status
- name: check service status
assert:
that:
- 'status.stdout == "active"'
- name: service status - enabled
command: systemctl is-enabled nftables.service
register: status
- name: check service status
assert:
that:
- 'status.stdout == "enabled"'

View File

@ -1,9 +1,7 @@
--- ---
- name: Converge - name: Converge
hosts: all hosts: all
gather_facts: yes
roles: roles:
- role: ipr-cnrs.nftables - role: ipr-cnrs.nftables
nft_debug: true
# can't remove iptables on an instance with docker
nft_old_pkg_manage: false

View File

@ -1,54 +1,11 @@
--- ---
dependency: dependency:
name: galaxy name: galaxy
lint: |
set -e
yamllint .
ansible-lint
driver: driver:
name: docker name: docker
platforms: platforms:
- name: instance
- name: systemd-ubuntu-latest image: ubuntu:latest
image: jrei/systemd-ubuntu:latest
command: /usr/sbin/init
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /run
- /tmp
- name: systemd-centos-latest
image: centos/systemd:latest
command: /usr/sbin/init
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /run
- /tmp
- name: systemd-debian-latest
image: jrei/systemd-debian:latest
command: /sbin/init
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /run
- /tmp
- name: systemd-fedora-latest
image: jrei/systemd-fedora:latest
command: /usr/sbin/init
privileged: true
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
tmpfs:
- /run
- /tmp
provisioner: provisioner:
name: ansible name: ansible
verifier: verifier:

View File

@ -5,68 +5,6 @@
hosts: all hosts: all
gather_facts: false gather_facts: false
tasks: tasks:
- name: Example assertion
- name: check for nftables.d
stat:
path: /etc/nftables.d
register: p
- name: check nftables.d
assert: assert:
that: that: true
- p.stat.exists and p.stat.isdir
- name: check for nftables.conf
stat:
path: /etc/nftables.conf
register: p
- name: check nftables.conf
assert:
that:
- p.stat.exists
- name: check for nftables.conf
stat:
path: /etc/nftables.d/filter-input.nft
register: p
- name: check filter-input.nft
assert:
that:
- p.stat.exists
- name: list rules
command: nft list ruleset
register: nft
- name: debug rules
debug: var=nft
- name: check rules
assert:
that:
# The whole line is:
# type filter hook input priority 0; policy drop;
# However on CentOS will return "priority 0", while Debian will
# show "priority filter"
- '"type filter hook input" in nft.stdout'
- '"type filter hook output" in nft.stdout'
- name: service status - active
command: systemctl is-active nftables.service
register: status
- name: check service status
assert:
that:
- 'status.stdout == "active"'
- name: service status - enabled
command: systemctl is-enabled nftables.service
register: status
- name: check service status
assert:
that:
- 'status.stdout == "enabled"'

View File

@ -13,8 +13,7 @@
loop_control: loop_control:
loop_var: groupname loop_var: groupname
- name: Debug nftables_group_rules - debug: var=nftables_group_rules
debug: var=nftables_group_rules
when: nft_debug when: nft_debug
- name: Import nftables-variables if nft_merged_groups is set - name: Import nftables-variables if nft_merged_groups is set
@ -37,12 +36,7 @@
loop_control: loop_control:
loop_var: varfile loop_var: varfile
- name: Debug nft_combined_rules - debug: var=nft_combined_rules
debug: var=nft_combined_rules
when: nft_debug
- name: Debug ansible_os_family
debug: var=ansible_os_family
when: nft_debug when: nft_debug
- name: Load specific OS vars for nftables - name: Load specific OS vars for nftables
@ -59,7 +53,6 @@
package: package:
name: '{{ nft_pkg_list | list }}' name: '{{ nft_pkg_list | list }}'
state: '{{ nft_pkg_state }}' state: '{{ nft_pkg_state }}'
update_cache: true
register: pkg_install_result register: pkg_install_result
until: pkg_install_result is success until: pkg_install_result is success
when: nft_enabled|bool when: nft_enabled|bool
@ -185,4 +178,5 @@
register: nftables__register_systemd_service register: nftables__register_systemd_service
when: (nft_enabled|bool and when: (nft_enabled|bool and
nft_service_manage|bool) nft_service_manage|bool)
notify: ['Restart nftables service'] notify: ['Restart nftables service']

View File

@ -1,4 +0,0 @@
---
# vars file for Alpine
nft_pkg_list:
- nftables

View File

@ -1,4 +0,0 @@
---
# vars file for Archlinux-based distros
nft_pkg_list:
- nftables