Skip to content
Proyek

konstruktoid/ansible-collection-hardening

Lihat di GitHub

Tentang

Ansible collection for Linux server hardening focused on systemd-based distributions including AlmaLinux, Debian, and Ubuntu.

Keamanan dan privasi

Cara angka ini diukur

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
+1
dalam 1 bulan
+3

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Ansible collection for Server Hardening

Ansible collection for hardening systemd-based Linux servers: AlmaLinux, Debian, and Ubuntu. It applies CIS Benchmark- and DISA STIG-aligned security controls through 44 independent, single-purpose roles covering SSH, sudo, PAM, auditd, sysctl, firewalling, mounts, and kernel modules, among other hardening domains.

Conversion of ansible-role-hardening to collection format.

See OVERVIEW.md for a high-level overview of the repository's purpose, components, and scope.

See PRESCRYB.md for how to use prescryb, a companion MCP server, to scan a hardened host for outstanding CVEs and compliance gaps and get Ansible remediation suggestions referencing this collection's roles.

Requirements

  • ansible-core >= 2.18.0

Some roles require the following additional collections:

Collection Minimum version Required by
ansible.posix 2.2.0 firewalld, mount, selinux, ufw
community.crypto 3.2.1 ssh
community.general 13.0.1 automatic_updates, disable_wireless, firewalld, ssh, ufw

ansible-galaxy installs them automatically with the collection. In a source checkout, install them with:

ansible-galaxy collection install -r requirements.yml

Supported platforms

Platform Versions
AlmaLinux / EL 10
Debian trixie
Ubuntu resolute

Platform support is declared per role in roles/<role>/meta/main.yml and is verified in CI against AlmaLinux 10, Debian trixie, and Ubuntu resolute container images (extensions/molecule/docker/molecule.yml).

Installation

ansible-galaxy collection install konstruktoid.hardening

Or add it to requirements.yml:

collections:
  - name: konstruktoid.hardening

Usage

Apply a single role:

- hosts: all
  become: true
  roles:
    - konstruktoid.hardening.ssh

Apply the full collection by including every role in roles/. Each role is independent and configured exclusively through its own variables in roles/<role>/defaults/main.yml; there is no top-level playbook or umbrella role. See each role's README.md for its variables and example usage.

Roles

Role Description Platforms
adduser Configure adduser and useradd. Debian, AlmaLinux/EL, Ubuntu
aide Installation and configuration of AIDE (Advanced Intrusion Detection Environment) on Linux systems. Debian, AlmaLinux/EL, Ubuntu
apparmor AppArmor installation and configuration. Debian, Ubuntu
apport Manage Apport. Debian, Ubuntu
auditd Install and configure auditd and manage audit rules on AlmaLinux, Debian, and Ubuntu. Debian, AlmaLinux/EL, Ubuntu
automatic_updates Configure unattended-upgrades to automatically install security updates. Debian, AlmaLinux/EL, Ubuntu
chrony Ansible role to manage chrony configuration. Debian, AlmaLinux/EL, Ubuntu
compilers Restrict compiler binaries to root on AlmaLinux, Debian, and Ubuntu systems. Debian, AlmaLinux/EL, Ubuntu
ctrlaltdel Disable Ctrl+Alt+Del key sequence to prevent reboots. Debian, AlmaLinux/EL, Ubuntu
delete_users Delete listed users. Debian, AlmaLinux/EL, Ubuntu
disable_ipv6 Disable IPv6 by configuring the net.ipv6.conf.*.disable_ipv6 sysctl keys and the GRUB kernel command line. Debian, AlmaLinux/EL, Ubuntu
disable_wireless Disable wireless interfaces and wireless kernel modules on AlmaLinux, Debian, and Ubuntu systems. Debian, AlmaLinux/EL, Ubuntu
file_permissions Restrict the ownership and permissions of the account databases and of the bootloader configuration files. Debian, AlmaLinux/EL, Ubuntu
firewalld An Ansible role to manage firewalld default-deny zone rules. AlmaLinux/EL
issue Role to update /etc/issue and /etc/motd files using Jinja2 templates. Debian, AlmaLinux/EL, Ubuntu
journald Configures systemd-journald storage, rotation, and file permissions; installs and configures rsyslog and logrotate for log forwarding and rotation; disables systemd-journal-remote. Debian, AlmaLinux/EL, Ubuntu
kernel Hardens kernel runtime behavior via sysctl and boot-time parameters: restricts virtual syscalls (vsyscall), enables page poisoning, kernel page-table isolation, SLUB debug poisoning, and kernel lockdown mode, using GRUB or grubby depending on the platform. Debian, AlmaLinux/EL, Ubuntu
kernel_modules Kernel module blocklist/blacklist management for AlmaLinux, Debian and Ubuntu. Debian, AlmaLinux/EL, Ubuntu
limits Configures PAM resource limits in /etc/security/limits.conf and systemd-coredump behavior in coredump.conf; disables the kdump crash-dump service. Debian, AlmaLinux/EL, Ubuntu
lock_root Lock the root account and remove root SSH authorized_keys. Debian, AlmaLinux/EL, Ubuntu
login_defs Configure /etc/login.defs settings to enforce secure account and password policy defaults on supported Linux systems. Debian, AlmaLinux/EL, Ubuntu
logindconf Configure systemd-logind settings by managing a logind.conf.d drop-in file. Debian, AlmaLinux/EL, Ubuntu
motd_news Manage apt esm, motd-news and Ubuntu PRO. Debian, Ubuntu
mount Manage /dev/shm, /proc and /tmp mounts. Debian, AlmaLinux/EL, Ubuntu
netplan Ensure netplan configuration permissions. Debian, AlmaLinux/EL, Ubuntu
package_management Role to manage configuration of APT and DNF. Debian, AlmaLinux/EL, Ubuntu
packages Ansible role to manage packages on Debian and RHEL based systems. Debian, AlmaLinux/EL, Ubuntu
password_management Configures PAM (common-auth, common-account, common-password, faillock, pwquality) and system-wide crypto-policies to enforce password quality requirements, hashing algorithm, account lockout, and FIPS mode. Debian, AlmaLinux/EL, Ubuntu
paths PATH and environment hardening for AlmaLinux, Debian, and Ubuntu systems. Debian, AlmaLinux/EL, Ubuntu
postfix Ansible role to harden Postfix MTA. Debian, AlmaLinux/EL, Ubuntu
prelink Disable prelink/prelinking on AlmaLinux, Debian, and Ubuntu systems. Debian, AlmaLinux/EL, Ubuntu
resolvedconf systemd-resolved configuration. Debian, AlmaLinux/EL, Ubuntu
root_access Limit root access using /etc/securetty, /etc/security/access.conf and masking debug-shell. Debian, AlmaLinux/EL, Ubuntu
schedulers Configure scheduled command services. Debian, AlmaLinux/EL, Ubuntu
selinux SELinux installation and configuration. AlmaLinux/EL
ssh SSH installation and configuration. Debian, AlmaLinux/EL, Ubuntu
sudo SUDO configuration and hardening. Debian, AlmaLinux/EL, Ubuntu
sysctl Applies kernel runtime hardening through sysctl: generic kernel, IPv4, and IPv6 network and memory-protection settings, with optional IPv6 disablement. Debian, AlmaLinux/EL, Ubuntu
systemdconf Ansible role to configure systemd system.conf and user.conf files. Debian, AlmaLinux/EL, Ubuntu
tcpwrappers tcpwrappers, hosts.allow and hosts.deny, management. Debian, AlmaLinux/EL, Ubuntu
timesyncd Ansible role to manage timesyncd configuration. Debian, AlmaLinux/EL, Ubuntu
ufw An Ansible role to manage UFW (Uncomplicated Firewall) rules. Debian, AlmaLinux/EL, Ubuntu
umask Configure system-wide default UMASK settings for AlmaLinux, Debian, and Ubuntu via login.defs, shell profiles, and PAM. Debian, AlmaLinux/EL, Ubuntu
usbguard Ansible role to manage USBGuard, a software for implementing USB device authorization policies. Debian, AlmaLinux/EL, Ubuntu

Testing

  • ansible-lint lints against profile: production (.ansible-lint).
  • molecule test -s docker converges every role in extensions/molecule/resources/converge.yml against AlmaLinux, Debian, and Ubuntu containers, checks idempotence, and runs the verifiers in extensions/molecule/tests/.
  • tox -e docker runs ansible-lint followed by molecule test -s docker.
  • tox -e devel and tox -e upstream run the same suite against the default scenario and against unpinned upstream ansible-core/ansible-lint, respectively.
  • The default scenario (extensions/molecule/default) boots the same three platforms as genericcloud qcow2 images directly under qemu-system-x86_64, instead of containers. It requires qemu-system-x86_64, qemu-img, genisoimage, and OVMF UEFI firmware installed on the host. After molecule converge, use molecule login --host resolute to open an SSH session to the Ubuntu guest.
  • The prerelease scenario (extensions/molecule/prerelease), run with molecule test -s prerelease or tox -e prerelease, uses the same QEMU provisioning and the same converge and verify playbooks, but against the current pre-release images: AlmaLinux Kitten 10, Debian 14 forky daily, and the Ubuntu development release. Those images move, so the scenario re-downloads them on every run and is expected to break occasionally. It runs weekly, and on demand, from .github/workflows/molecule-prerelease.yml, which is deliberately not triggered by pull requests so that it never gates a merge.

Security

See SECURITY.md for the supported-versions policy and vulnerability reporting.

License

Apache-2.0. See LICENSE.

Jelajahi proyek terkait

Memuat…