ansible-collection-hardening
This Ansible collection provides battle tested hardening for Linux, SSH, nginx, MySQL
Quick Overview
The dev-sec/ansible-collection-hardening
repository is an Ansible collection that provides a set of Ansible roles and playbooks for hardening various operating systems and applications. It is designed to help organizations improve the security posture of their infrastructure by applying best practices and recommendations from industry standards such as CIS, DISA STIG, and NIST.
Pros
- Comprehensive Coverage: The collection includes roles for hardening a wide range of operating systems, including Linux, Windows, and macOS, as well as various applications and services.
- Automated Deployment: The Ansible playbooks and roles allow for the automated deployment and configuration of security controls, reducing the manual effort required.
- Customizable: The collection provides a modular and flexible design, allowing users to customize the security controls to fit their specific requirements.
- Community-Driven: The project is actively maintained and supported by a community of security professionals, ensuring regular updates and improvements.
Cons
- Complexity: Implementing the full set of security controls provided by the collection may require a significant investment of time and resources, especially for organizations with large or complex infrastructures.
- Potential Compatibility Issues: The collection may not be compatible with all versions of the supported operating systems and applications, which could lead to compatibility issues or the need for additional customization.
- Ongoing Maintenance: Maintaining the security posture of the infrastructure requires continuous monitoring and updating of the security controls, which can be time-consuming and resource-intensive.
- Limited Visibility: The collection may not provide comprehensive visibility into the security posture of the infrastructure, which could make it difficult to assess the effectiveness of the implemented controls.
Getting Started
To get started with the dev-sec/ansible-collection-hardening
repository, follow these steps:
-
Install Ansible on your control node.
-
Install the
dev-sec.hardening
Ansible collection:ansible-galaxy collection install dev-sec.hardening
-
Create an Ansible playbook that includes the desired roles from the collection. For example, to harden a CentOS 7 system, you can use the following playbook:
- hosts: all become: true collections: - dev-sec.hardening roles: - os_hardening - ssh_hardening - mysql_hardening
-
Run the playbook:
ansible-playbook playbook.yml
-
Verify the applied security controls and monitor the infrastructure for any changes or security incidents.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Ansible Collection - devsec.hardening
Description
This collection provides battle tested hardening for:
- Linux operating systems:
- CentOS 9
- Rocky Linux 8/9
- Debian 11/12
- Ubuntu 20.04/22.04/24.04
- Amazon Linux (some roles supported)
- Arch Linux (some roles supported)
- Fedora 39/40 (some roles supported)
- Suse Tumbleweed (some roles supported)
- MySQL
- MariaDB >= 5.5.65, >= 10.1.45, >= 10.3.17
- MySQL >= 5.7.31, >= 8.0.3
- Nginx 1.0.16 or later
- OpenSSH 5.3 and later
The hardening is intended to be compliant with the Inspec DevSec Baselines:
- https://github.com/dev-sec/linux-baseline
- https://github.com/dev-sec/mysql-baseline
- https://github.com/dev-sec/nginx-baseline
- https://github.com/dev-sec/ssh-baseline
Looking for the old roles?
The roles are now part of the hardening-collection.
We have kept the old releases of the os-hardening
role in this repository, so you can find the them by exploring older tags.
The last release of the standalone role was 6.2.0.
The other roles are in separate archives repositories:
Minimum required Ansible-version
- Ansible >= 2.9.10
Included content
In progress, not working:
Installation
Install the collection via ansible-galaxy:
ansible-galaxy collection install devsec.hardening
Using this collection
Please refer to the examples in the readmes of the role.
See Ansible Using collections for more details.
Contributing to this collection
See the contributor guideline.
Release notes
See the changelog.
Roadmap
Todos:
- Work on apache_hardening and windows_hardening
- Add support for more operating systems
More information
General information:
- Ansible Collection overview
- Ansible User guide
- Ansible Developer guide
- Ansible Collections Checklist
- Ansible Community code of conduct
- The Bullhorn (the Ansible Contributor newsletter)
- Changes impacting Contributors
Licensing
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot