Prototype a role for installing fail2ban on RHEL 9+

This commit is contained in:
Alexander Gorelyshev
2026-06-08 20:05:29 +04:00
parent fad0cb0abb
commit deaeb1f79e
9 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
- name: Converge
hosts: all
roles:
- role: genlab.common.fail2ban_rhel

View File

@@ -0,0 +1,27 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: rocky9
image: geerlingguy/docker-${MOLECULE_DISTRO:-rockylinux9}-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 .

View File

@@ -0,0 +1,17 @@
---
- name: Verify
hosts: all
gather_facts: false
any_errors_fatal: true
tasks:
- name: "Check that the fail2ban service is active"
register: sshd_rhel_fail2ban_service
ansible.builtin.systemd:
name: fail2ban
- name: "Assert fail2ban is running"
ansible.builtin.assert:
that: sshd_rhel_fail2ban_service.status.ActiveState == "active"
success_msg: "fail2ban service is running"
fail_msg: "fail2ban service is not active"