add ufw role
This commit is contained in:
17
roles/ufw/molecule/default/converge.yml
Normal file
17
roles/ufw/molecule/default/converge.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
vars:
|
||||
custom_rules:
|
||||
- port: 80
|
||||
- port: 9080
|
||||
src: "10.2.1.0/24"
|
||||
- interface: eth0@if288
|
||||
direction: in
|
||||
comment: "Allow all incoming traffic on eth0@if288"
|
||||
|
||||
roles:
|
||||
- role: genlab.ufw
|
||||
disable_ipv6: true
|
||||
limit_ssh: true
|
||||
rules: "{{ custom_rules }}"
|
||||
27
roles/ufw/molecule/default/molecule.yml
Normal file
27
roles/ufw/molecule/default/molecule.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
platforms:
|
||||
- name: ubuntu
|
||||
image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2204}-ansible:latest
|
||||
pre_build_image: true
|
||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||
volumes:
|
||||
- /sys/fs/cgroup:/sys/fs/cgroup:rw
|
||||
cgroupns_mode: host
|
||||
privileged: true
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
|
||||
verifier:
|
||||
name: ansible
|
||||
|
||||
lint: |
|
||||
set -e
|
||||
yamllint .
|
||||
ansible-lint .
|
||||
28
roles/ufw/molecule/default/verify.yml
Normal file
28
roles/ufw/molecule/default/verify.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
- name: Verify
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
any_errors_fatal: true
|
||||
|
||||
tasks:
|
||||
- name: "Get the UFW status"
|
||||
register: ufw_status
|
||||
changed_when: false
|
||||
ansible.builtin.command:
|
||||
cmd: ufw status
|
||||
|
||||
- name: "Verify expected UFW status"
|
||||
vars:
|
||||
expected:
|
||||
- "Status: active"
|
||||
- ""
|
||||
- "To Action From"
|
||||
- "-- ------ ----"
|
||||
- "22/tcp LIMIT Anywhere "
|
||||
- "80 ALLOW Anywhere "
|
||||
- "9080 ALLOW 10.2.1.0/24 "
|
||||
- "Anywhere on eth0@if288 ALLOW Anywhere # Allow all incoming traffic on eth0@if288"
|
||||
ansible.builtin.assert:
|
||||
that: ufw_status.stdout_lines == expected
|
||||
success_msg: "UFW has the expected state"
|
||||
fail_msg: "Unexpected UFW state (some rules may have not been applied correctly)"
|
||||
Reference in New Issue
Block a user