Compare commits

...
20 Commits
Author SHA1 Message Date
Daniel Kubat 7077187a67 replace module parameter fixed (#297)
Signed-off-by: danielkubat <[email protected]>
2020-08-17 12:15:04 +02:00
dev-sec CI 37ab009093 update changelog 2020-08-16 18:19:43 +00:00
schurzi 56f6cd0337 Merge pull request #296 from dev-sec/fedora
fix fedora build
2020-08-16 20:17:15 +02:00
dev-sec CI 337c7dbbed update changelog 2020-08-16 08:06:54 +00:00
Daniel KubatandSebastian Gumprich 2c4505addd use find module instead of shell (#294)
* use find module to find yum repos, regexp fixes

Signed-off-by: danielkubat <[email protected]>

* use loop instead of with_*

Signed-off-by: danielkubat <[email protected]>

* Update tasks/yum.yml

Co-authored-by: Sebastian Gumprich <[email protected]>
2020-08-16 10:04:26 +02:00
Sebastian Gumprich 88fecc4f2e try to fix fedora build
Signed-off-by: Sebastian Gumprich <[email protected]>
2020-08-16 09:53:11 +02:00
dev-sec CI c777133050 update changelog 2020-08-13 09:48:20 +00:00
Alex Domoradov 29158e4285 Optimize and unify when clause (#295)
Signed-off-by: Alex Domoradov <[email protected]>
2020-08-13 11:45:44 +02:00
dev-sec CI eb777fbe2f update changelog 2020-08-07 07:02:27 +00:00
schurzi eaeca04d96 do not blacklist used filesystems (#289)
* add additional check for efi

some systems seem to require vfat because of efi, despite not exposing a
/sys/firmware/efi directory.

Signed-off-by: Martin Schurz <[email protected]>

* make linter happy

Signed-off-by: Martin Schurz <[email protected]>

* rework check to check for all used filesystems

so we don't break existing mounts with our configuration

Signed-off-by: Martin Schurz <[email protected]>

* do not check this on el6

Signed-off-by: Martin Schurz <[email protected]>

* add comment to clarify

Signed-off-by: Martin Schurz <[email protected]>
2020-08-07 08:59:46 +02:00
dev-sec CI fe7e37e6e9 update changelog 2020-08-03 13:58:20 +00:00
schurzi 387fc472bd improve testing (#287)
* fix problem with package_facts on SuSE

SuSE Linux does not work with ansibel module packet_facts, so we need to
exclude this task there.

Signed-off-by: Martin Schurz <[email protected]>

* fix local docker tests for all distributions

Signed-off-by: Martin Schurz <[email protected]>

* fix local vagrant tests for all distributions

Signed-off-by: Martin Schurz <[email protected]>

* simplify travis tests

Signed-off-by: Martin Schurz <[email protected]>

* fix opensuse in travis

Signed-off-by: Martin Schurz <[email protected]>

* add fixes for suse

Signed-off-by: Martin Schurz <[email protected]>

* add special case for suse docker

Signed-off-by: Martin Schurz <[email protected]>
2020-08-03 15:55:27 +02:00
dev-sec CI 740feae180 update changelog 2020-07-22 19:29:59 +00:00
Sebastian Gumprich 65a8fa0c6c move hidepid vars into defaults so theyre overwritable (#285)
fixes #284

Signed-off-by: Sebastian Gumprich <[email protected]>
2020-07-22 21:27:25 +02:00
dev-sec CI 994ea81e64 update changelog 2020-07-21 20:38:28 +00:00
alegrey91andSebastian Gumprich a8e349913d Mount proc filesystem using hidepid option (#283)
* Added task to mount proc fs using hidepid option

Signed-off-by: alessio <[email protected]>
Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Removed mount shell command due to ci problem

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Added task to create mount point before to add fstab entry

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Added check to ensure fstab exist

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Modified task title

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Fixed typo

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Fixed typo

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Fixed wrong indented lines

Signed-off-by: alegrey91 <[email protected]>
Signed-off-by: alessio <[email protected]>

* Removed useless tasks and improved variables use

Signed-off-by: alessio <[email protected]>

* removed ansible test tag

Signed-off-by: alessio <[email protected]>

* removed trailing whitespace

Signed-off-by: alessio <[email protected]>

* updated documentation

Signed-off-by: alessio <[email protected]>

* fixed typo

Signed-off-by: alessio <[email protected]>

* Update README.md

* Update vars/main.yml

Co-authored-by: Sebastian Gumprich <[email protected]>
2020-07-21 22:35:50 +02:00
dev-sec CI 476f2ec8e2 update changelog 2020-07-12 07:18:50 +00:00
Sebastian Gumprich 990f95807f remove mention of gitter 2020-07-12 09:16:22 +02:00
dev-sec CI 8d8277b3bd update changelog 2020-07-05 17:03:53 +00:00
Sebastian Gumprich 4d34d24c32 install procps in debian so sysctl.conf exists (#282)
Signed-off-by: Sebastian Gumprich <[email protected]>
2020-07-05 19:01:21 +02:00
18 changed files with 213 additions and 113 deletions

No files matched your search

+11
View File
@@ -33,6 +33,9 @@ platforms:
- name: centos-6
driver_config:
box: bento/centos-6.7
provision: true
vagrantfiles:
- rhel6_provision.rb
- name: centos-7
driver_config:
box: bento/centos-7
@@ -42,6 +45,9 @@ platforms:
- name: oracle-6
driver_config:
box: bento/oracle-6
provision: true
vagrantfiles:
- rhel6_provision.rb
- name: oracle-7
driver_config:
box: bento/oracle-7
@@ -57,6 +63,11 @@ platforms:
- name: opensuse_tumbleweed
driver_config:
box: opensuse/Tumbleweed.x86_64
provision: true
vagrantfiles:
- suse_provision.rb
provisioner:
ansible_binary_path: "/usr/local/bin"
verifier:
name: inspec
+40 -18
View File
@@ -2,7 +2,16 @@
driver:
name: docker
use_sudo: false
privileged: true
cap_add:
- SYS_ADMIN
volume:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
run_options:
tmpfs:
- /tmp
- /run
- /run/lock
run_command: /sbin/init
http_proxy: <%= ENV['http_proxy'] || nil %>
https_proxy: <%= ENV['https_proxy'] || nil %>
@@ -28,95 +37,108 @@ platforms:
driver:
image: rndmh3ro/docker-centos6-ansible:latest
platform: centos
provision_command:
- sed -i '/loginuid/d' /etc/pam.d/sshd
- name: centos7-ansible-latest
driver:
image: rndmh3ro/docker-centos7-ansible:latest
platform: centos
run_command: /sbin/init
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- sed -i '/nologin/d' /etc/pam.d/sshd
- systemctl enable sshd.service
- name: centos8-ansible-latest
driver:
image: rndmh3ro/docker-centos8-ansible:latest
platform: centos
run_command: /sbin/init
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- sed -i '/nologin/d' /etc/pam.d/sshd
- systemctl enable sshd.service
provisioner:
ansible_binary_path: "/usr/local/bin"
- name: oracle6-ansible-latest
driver:
image: rndmh3ro/docker-oracle6-ansible:latest
platform: centos
provision_command:
- sed -i '/loginuid/d' /etc/pam.d/sshd
- name: oracle7-ansible-latest
driver:
image: rndmh3ro/docker-oracle7-ansible:latest
run_command: /sbin/init
platform: centos
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- yum -y install initscripts
- sed -i '/nologin/d' /etc/pam.d/sshd
- systemctl enable sshd.service
- name: ubuntu1604-ansible-latest
driver:
image: rndmh3ro/docker-ubuntu1604-ansible:latest
platform: ubuntu
run_command: /sbin/init
provision_command:
- systemctl enable ssh.service
- name: ubuntu1804-ansible-latest
driver:
image: rndmh3ro/docker-ubuntu1804-ansible:latest
platform: ubuntu
run_command: /sbin/init
provision_command:
- systemctl enable ssh.service
- name: debian9-ansible-latest
driver:
image: rndmh3ro/docker-debian9-ansible:latest
platform: debian
run_command: /sbin/init
provision_command:
- apt install -y systemd-sysv
- systemctl enable ssh.service
- name: debian10-ansible-latest
driver:
image: rndmh3ro/docker-debian10-ansible:latest
platform: debian
run_command: /sbin/init
provision_command:
- apt install -y systemd-sysv
- systemctl enable ssh.service
- name: amazon-ansible-latest
driver:
image: rndmh3ro/docker-amazon-ansible:latest
platform: centos
run_command: /sbin/init
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- sed -i '/nologin/d' /etc/pam.d/sshd
- systemctl enable sshd.service
- name: fedora-ansible-latest
driver:
image: rndmh3ro/docker-fedora-ansible:latest
platform: centos
run_command: /sbin/init
provision_command:
- dnf install -y python
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- sed -i '/nologin/d' /etc/pam.d/sshd
- systemctl enable sshd.service
- name: opensuse_tumbleweed-ansible-latest
driver:
image: rndmh3ro/docker-opensuse_tumbleweed-ansible
platform: opensuse
provision_command:
- zypper -n install python-xml rpm-python
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- zypper -n install python-xml
- sed -i '/nologin/d' /etc/pam.d/sshd
- sed -i '/systemd/d' /etc/pam.d/common-session
- systemctl enable sshd.service
verifier:
name: inspec
sudo: true
inspec_tests:
- https://github.com/dev-sec/tests-os-hardening
- https://github.com/dev-sec/linux-baseline
controls:
# skip sysctl checks, since they make no sense in docker
- /^(?!sysctl-|package-07).+/
suites:
- name: os
+27 -59
View File
@@ -2,63 +2,31 @@
services: docker
env:
- distro: centos6
version: latest
init: /sbin/init
- distro: centos7
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
version: latest
- distro: centos8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
version: latest
- distro: fedora
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
version: latest
- distro: oracle6
version: latest
init: /sbin/init
# - distro: oracle7
# init: /lib/systemd/systemd
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# version: latest
- distro: ubuntu1604
version: latest
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: ubuntu1804
version: latest
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: debian9
version: latest
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: debian10
version: latest
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: amazon
init: /lib/systemd/systemd
version: latest
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# - distro: opensuse_tumbleweed
# init: /usr/lib/systemd/systemd
# version: latest
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro --volume=/run:/run:ro"
global:
- version=latest
- init=/sbin/init
- run_opts="--cap-add SYS_ADMIN"
- volume="/sys/fs/cgroup:/sys/fs/cgroup:ro"
jobs:
- distro=centos6
volume=":"
run_opts=""
- distro=centos7
- distro=centos8
- distro=oracle6
volume=":"
run_opts=""
# - distro=oracle7
- distro=ubuntu1604
- distro=ubuntu1804
- distro=debian9
init=/lib/systemd/systemd
- distro=debian10
- distro=amazon
- distro=fedora
init=/lib/systemd/systemd
- distro=opensuse_tumbleweed
run_opts="--privileged"
before_install:
# Pull container
@@ -70,7 +38,7 @@ script:
- container_id=$(mktemp)
# Run container in detached state.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/ansible-os-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
- 'docker run --detach --volume="${volume}" --volume="${PWD}":/etc/ansible/roles/ansible-os-hardening:ro ${run_opts} rndmh3ro/docker-${distro}-ansible:${version} "${init}" > "${container_id}"'
# Output Ansible version from docker image
- 'docker exec "$(cat ${container_id})" ansible-playbook --version'
@@ -79,7 +47,7 @@ script:
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/ansible-os-hardening/tests/test.yml --diff'
# Verify role
- 'inspec exec https://github.com/dev-sec/linux-baseline/ -t docker://$(cat ${container_id}) --controls=os-01 os-02 os-03 os-04 os-05 os-05b os-06 os-07 os-09 os-10 os-11 package-01 package-02 package-03 package-05 package-06 package-08 package-09 --no-distinct-exit'
- 'inspec exec https://github.com/dev-sec/linux-baseline/ -t docker://$(cat ${container_id}) --no-distinct-exit'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
+52 -5
View File
@@ -1,10 +1,57 @@
# Changelog
## [6.2.0](https://github.com/dev-sec/ansible-os-hardening/tree/6.2.0) (2020-08-16)
[Full Changelog](https://github.com/dev-sec/ansible-os-hardening/compare/6.1.0...6.2.0)
**Implemented enhancements:**
- Optimize and unify when clause [\#295](https://github.com/dev-sec/ansible-os-hardening/pull/295) ([Alexhha](https://github.com/Alexhha))
- use find module instead of shell [\#294](https://github.com/dev-sec/ansible-os-hardening/pull/294) ([danielkubat](https://github.com/danielkubat))
- improve testing [\#287](https://github.com/dev-sec/ansible-os-hardening/pull/287) ([schurzi](https://github.com/schurzi))
**Fixed bugs:**
- Inconsistent use of role vars/role defaults [\#284](https://github.com/dev-sec/ansible-os-hardening/issues/284)
**Closed issues:**
- Consider using find module instead of shell [\#293](https://github.com/dev-sec/ansible-os-hardening/issues/293)
- Optimize logical OR in when clause [\#292](https://github.com/dev-sec/ansible-os-hardening/issues/292)
- vfat added to dev-sec.conf, but efi is used [\#288](https://github.com/dev-sec/ansible-os-hardening/issues/288)
- OpenSUSE Support [\#249](https://github.com/dev-sec/ansible-os-hardening/issues/249)
**Merged pull requests:**
- fix fedora build [\#296](https://github.com/dev-sec/ansible-os-hardening/pull/296) ([rndmh3ro](https://github.com/rndmh3ro))
- move hidepid vars into defaults so theyre overwritable [\#285](https://github.com/dev-sec/ansible-os-hardening/pull/285) ([rndmh3ro](https://github.com/rndmh3ro))
## [6.1.0](https://github.com/dev-sec/ansible-os-hardening/tree/6.1.0) (2020-07-21)
[Full Changelog](https://github.com/dev-sec/ansible-os-hardening/compare/6.0.3...6.1.0)
**Implemented enhancements:**
- Mount proc filesystem using hidepid option [\#283](https://github.com/dev-sec/ansible-os-hardening/pull/283) ([alegrey91](https://github.com/alegrey91))
**Fixed bugs:**
- Is it safe to use on Debian 10? The build is failing. [\#281](https://github.com/dev-sec/ansible-os-hardening/issues/281)
**Closed issues:**
- The state of the galaxy release [\#269](https://github.com/dev-sec/ansible-os-hardening/issues/269)
**Merged pull requests:**
- do not blacklist used filesystems [\#289](https://github.com/dev-sec/ansible-os-hardening/pull/289) ([schurzi](https://github.com/schurzi))
- install procps in debian so sysctl.conf exists [\#282](https://github.com/dev-sec/ansible-os-hardening/pull/282) ([rndmh3ro](https://github.com/rndmh3ro))
## [6.0.3](https://github.com/dev-sec/ansible-os-hardening/tree/6.0.3) (2020-06-06)
[Full Changelog](https://github.com/dev-sec/ansible-os-hardening/compare/6.0.2...6.0.3)
**Merged pull requests:**
**Implemented enhancements:**
- unify changelog and release actions [\#279](https://github.com/dev-sec/ansible-os-hardening/pull/279) ([rndmh3ro](https://github.com/rndmh3ro))
@@ -35,7 +82,7 @@
- Add Debian Buster support for ansible-os-hardening [\#233](https://github.com/dev-sec/ansible-os-hardening/issues/233)
- Add CentOS 8 support for ansible-os-hardening [\#232](https://github.com/dev-sec/ansible-os-hardening/issues/232)
- Add selinux configuration [\#154](https://github.com/dev-sec/ansible-os-hardening/issues/154)
- Make useradd defaults in login.defs dependent on OS [\#266](https://github.com/dev-sec/ansible-os-hardening/pull/266) ([Aisbergg](https://github.com/Aisbergg))
- Make useradd defaults in login.defs dependent on OS [\#266](https://github.com/dev-sec/ansible-os-hardening/pull/266) ([aisbergg](https://github.com/aisbergg))
- Add kernel hardening parameters from Tails and CIS Benchmark [\#263](https://github.com/dev-sec/ansible-os-hardening/pull/263) ([kravietz](https://github.com/kravietz))
- add ansible-lint [\#262](https://github.com/dev-sec/ansible-os-hardening/pull/262) ([rndmh3ro](https://github.com/rndmh3ro))
- Remove trailing space [\#261](https://github.com/dev-sec/ansible-os-hardening/pull/261) ([kravietz](https://github.com/kravietz))
@@ -139,9 +186,7 @@
- Rename pam\_passwdqd.j2 to pam\_passwdqc.j2 [\#172](https://github.com/dev-sec/ansible-os-hardening/pull/172) ([martinbydefault](https://github.com/martinbydefault))
- Use package state 'present' since 'installed' is deprecated [\#168](https://github.com/dev-sec/ansible-os-hardening/pull/168) ([Normo](https://github.com/Normo))
- Update syntax to Ansible 2.4 [\#161](https://github.com/dev-sec/ansible-os-hardening/pull/161) ([thomasjpfan](https://github.com/thomasjpfan))
- add amazon linux testing [\#160](https://github.com/dev-sec/ansible-os-hardening/pull/160) ([rndmh3ro](https://github.com/rndmh3ro))
- Add support for Amazon Linux [\#158](https://github.com/dev-sec/ansible-os-hardening/pull/158) ([woneill](https://github.com/woneill))
- install and configure auditd - fix inspec package-08 [\#144](https://github.com/dev-sec/ansible-os-hardening/pull/144) ([rndmh3ro](https://github.com/rndmh3ro))
- Remove deprecated include for static tasks and use instead import\_tasks fix \#131 [\#132](https://github.com/dev-sec/ansible-os-hardening/pull/132) ([HelioCampos](https://github.com/HelioCampos))
**Fixed bugs:**
@@ -164,12 +209,14 @@
- Update some RH settings in this role [\#155](https://github.com/dev-sec/ansible-os-hardening/issues/155)
- Removal of core dump hardening configuration if core dumps are allowed [\#129](https://github.com/dev-sec/ansible-os-hardening/issues/129)
- add amazon linux testing [\#160](https://github.com/dev-sec/ansible-os-hardening/pull/160) ([rndmh3ro](https://github.com/rndmh3ro))
- Don't create home for system accounts [\#156](https://github.com/dev-sec/ansible-os-hardening/pull/156) ([oakey-b1](https://github.com/oakey-b1))
- Prevent disabling of filesystems via whitelist [\#153](https://github.com/dev-sec/ansible-os-hardening/pull/153) ([manuelprinz](https://github.com/manuelprinz))
- Add kernel hardening settings from Ubuntu /etc/sysctl.d [\#150](https://github.com/dev-sec/ansible-os-hardening/pull/150) ([kravietz](https://github.com/kravietz))
- Removal of core dump hardening configuration if core dumps are allowed [\#146](https://github.com/dev-sec/ansible-os-hardening/pull/146) ([martinbydefault](https://github.com/martinbydefault))
- add missing sysctl parameter [\#143](https://github.com/dev-sec/ansible-os-hardening/pull/143) ([rndmh3ro](https://github.com/rndmh3ro))
- update readme [\#139](https://github.com/dev-sec/ansible-os-hardening/pull/139) ([rndmh3ro](https://github.com/rndmh3ro))
- add modprobe template, control os-10 [\#138](https://github.com/dev-sec/ansible-os-hardening/pull/138) ([rndmh3ro](https://github.com/rndmh3ro))
**Fixed bugs:**
@@ -200,7 +247,7 @@
**Implemented enhancements:**
- add modprobe template, control os-10 [\#138](https://github.com/dev-sec/ansible-os-hardening/pull/138) ([rndmh3ro](https://github.com/rndmh3ro))
- install and configure auditd - fix inspec package-08 [\#144](https://github.com/dev-sec/ansible-os-hardening/pull/144) ([rndmh3ro](https://github.com/rndmh3ro))
- new task for delete netrc files, control os-09 [\#137](https://github.com/dev-sec/ansible-os-hardening/pull/137) ([rndmh3ro](https://github.com/rndmh3ro))
- add passwd task, control os-03 [\#136](https://github.com/dev-sec/ansible-os-hardening/pull/136) ([rndmh3ro](https://github.com/rndmh3ro))
- remove prelink package, control package-09 [\#135](https://github.com/dev-sec/ansible-os-hardening/pull/135) ([rndmh3ro](https://github.com/rndmh3ro))
+2 -1
View File
@@ -1,7 +1,6 @@
# os-hardening (Ansible Role)
[![Build Status](http://img.shields.io/travis/dev-sec/ansible-os-hardening.svg)][1]
[![Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)][2]
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-os--hardening-660198.svg)][3]
## Description
@@ -81,6 +80,8 @@ If you're using Docker / Kubernetes+Docker you'll need to override the ipv4 ip f
| `ufw_default_forward_policy` | DROP | set default forward policy of ufw to `DROP` |
| `os_auditd_enabled` | true | Set to false to disable installing and configuring auditd. |
| `os_auditd_max_log_file_action` | `keep_logs` | Defines the behaviour of auditd when its log file is filled up. Possible other values are described in the auditd.conf man page. The most common alternative to the default may be `rotate`. |
| `hidepid_option` | `2` | `0`: This is the default setting and gives you the default behaviour. `1`: With this option an normal user would not see other processes but their own about ps, top etc, but he is still able to see process IDs in /proc. `2`: Users are only able too see their own processes (like with hidepid=1), but also the other process IDs are hidden for them in /proc. |
| `proc_mnt_options` | `rw,nosuid,nodev,noexec,relatime,hidepid={{ hidepid_option }}` | Mount proc with hardenized options, including `hidepid` with variable value. |
## Packages
+3
View File
@@ -278,3 +278,6 @@ os_auditd_max_log_file_action: keep_logs
os_selinux_state: enforcing
# Set the SELinux polixy.
os_selinux_policy: targeted
hidepid_option: '2' # allowed values: 0, 1, 2
proc_mnt_options: 'rw,nosuid,nodev,noexec,relatime,hidepid={{ hidepid_option }}'
+7
View File
@@ -0,0 +1,7 @@
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
rpm -i http://mirror.de.leaseweb.net/epel/6/x86_64/epel-release-6-8.noarch.rpm
sed -i 's/\\(mirrorlist=http\\)s/\\1/' /etc/yum.repos.d/epel.repo
yum install -y ansible libselinux-python
SHELL
end
+7
View File
@@ -0,0 +1,7 @@
Vagrant.configure(2) do |config|
config.vm.provision "shell", inline: <<-SHELL
zypper -n install python2-setuptools
mkdir -p /usr/local/lib/python2.7/site-packages/
ln -s /usr/local/bin/pip /usr/bin/
SHELL
end
-1
View File
@@ -1,5 +1,4 @@
---
- name: install auditd package | package-08
package:
name: '{{ auditd_package }}'
+2 -3
View File
@@ -56,10 +56,9 @@
tags: yum
- import_tasks: apt.yml
when: ansible_facts.distribution == 'Debian' or ansible_facts.distribution == 'Ubuntu'
when: ansible_facts.distribution in ['Debian', 'Ubuntu']
tags: apt
- import_tasks: selinux.yml
tags: selinux
when:
- ansible_facts.selinux.status == 'enabled'
when: ansible_facts.selinux.status == 'enabled'
-1
View File
@@ -1,5 +1,4 @@
---
- block:
- name: create limits.d-directory if it does not exist | sysctl-31a, sysctl-31b
file:
-1
View File
@@ -1,4 +1,3 @@
---
- import_tasks: hardening.yml
when: os_hardening_enabled | bool
+8
View File
@@ -48,3 +48,11 @@
group: 'root'
mode: '0750'
when: '"change_user" not in os_security_users_allow'
- name: set option hidepid for proc filesystem
mount:
path: /proc
src: proc
fstype: proc
opts: '{{ proc_mnt_options }}'
state: present
+9 -1
View File
@@ -12,7 +12,15 @@
- name: remove vfat from fs-list if efi is used
set_fact:
os_unused_filesystems: "{{ os_unused_filesystems | difference('vfat') }}"
when: efi_installed.stat.isdir is defined and efi_installed.stat.isdir
when:
- efi_installed.stat.isdir is defined
- efi_installed.stat.isdir
- name: remove used filesystems from fs-list
set_fact:
os_unused_filesystems: "{{ os_unused_filesystems | difference(ansible_mounts | map(attribute='fstype') | list) }}"
# we cannot do this on el6 and below, because these systems don't support the map function
when: not ((ansible_facts.os_family in ['Oracle Linux', 'RedHat']) and ansible_facts.distribution_major_version < '7')
- name: disable unused filesystems | os-10
template:
+4 -1
View File
@@ -121,6 +121,7 @@
- name: Gather package facts
package_facts:
manager: auto
when: ansible_facts.os_family != 'Suse'
- name: NSA 2.3.3.5 Upgrade Password Hashing Algorithm to SHA-512
template:
@@ -129,4 +130,6 @@
mode: '0640'
owner: 'root'
group: 'root'
when: "'libuser' in ansible_facts.packages"
when:
- ansible_facts.os_family != 'Suse'
- "'libuser' in ansible_facts.packages"
+12 -7
View File
@@ -13,15 +13,16 @@
owner: 'root'
group: 'root'
mode: '0544'
when: ansible_facts.distribution == 'RedHat' or ansible_facts.distribution == 'Fedora' or
ansible_facts.distribution == 'CentOS' or ansible_facts.distribution == 'Amazon'
when: ansible_facts.distribution in ['Amazon', 'CentOS', 'Fedora', 'RedHat']
- name: install initramfs-tools
apt:
name: 'initramfs-tools'
state: 'present'
update_cache: true
when: ansible_facts.os_family == 'Debian' and os_security_kernel_enable_module_loading
when:
- ansible_facts.os_family == 'Debian'
- os_security_kernel_enable_module_loading
- name: rebuild initramfs with starting pack of modules, if module loading at runtime is disabled
template:
@@ -32,7 +33,9 @@
mode: '0440'
notify:
- update-initramfs
when: ansible_facts.os_family == 'Debian' and os_security_kernel_enable_module_loading
when:
- ansible_facts.os_family == 'Debian'
- os_security_kernel_enable_module_loading
register: initramfs
- name: change sysctls
@@ -60,14 +63,16 @@
reload: yes
ignoreerrors: yes
with_dict: '{{ sysctl_rhel_config }}'
when: ((ansible_facts.distribution == 'RedHat' or ansible_facts.distribution == 'Fedora' or ansible_facts.distribution == 'CentOS') and
when: ((ansible_facts.distribution in ['CentOS', 'Fedora', 'RedHat']) and
ansible_distribution_version|int is version('7', '<')) or ansible_facts.distribution == 'Amazon'
when: ansible_virtualization_type not in ['docker', 'openvz', 'lxc']
when: ansible_virtualization_type not in ['docker', 'lxc', 'openvz']
- name: Apply ufw defaults
template:
src: 'etc/default/ufw.j2'
dest: '/etc/default/ufw'
when: ufw_manage_defaults and (ansible_facts.distribution == 'Debian' or ansible_facts.distribution == 'Ubuntu')
when:
- ufw_manage_defaults
- ansible_facts.distribution in ['Debian', 'Ubuntu']
tags: ufw
+22 -15
View File
@@ -3,35 +3,42 @@
file:
name: '/etc/yum.repos.d/{{ item }}.repo'
state: 'absent'
with_items:
loop:
- 'CentOS-Debuginfo'
- 'CentOS-Media'
- 'CentOS-Vault'
when: os_security_packages_clean | bool
- name: get yum-repository-files
shell: 'find /etc/yum.repos.d/ -type f -name *.repo'
changed_when: False
find:
paths: '/etc/yum.repos.d'
patterns: '*.repo'
register: yum_repos
# for the 'default([])' see here:
# https://github.com/dev-sec/ansible-os-hardening/issues/99 and
# https://stackoverflow.com/questions/37067827/ansible-deprecation-warning-for-undefined-variable-despite-when-clause
#
# failed_when is needed because by default replace module will fail if the file doesn't exists.
# status.rc is only defined if an error accrued and only error code (rc) 257 will be ignored.
# All other errors will still be raised.
# for the 'default([])' see here:
# https://github.com/dev-sec/ansible-os-hardening/issues/99 and
# https://stackoverflow.com/questions/37067827/ansible-deprecation-warning-for-undefined-variable-despite-when-clause
- name: activate gpg-check for yum-repository-files
replace:
path: '{{ item.path }}'
regexp: '^\s*gpgcheck.*'
replace: 'gpgcheck=1'
with_items:
- '{{ yum_repos.files | default([]) }}'
# failed_when is needed because by default replace module will fail if the file doesn't exists.
# status.rc is only defined if an error accrued and only error code (rc) 257 will be ignored.
# All other errors will still be raised.
- name: activate gpg-check for config files
replace:
dest: '{{ item }}'
regexp: '^\s*gpgcheck: 0'
replace: 'gpgcheck: 1'
path: '{{ item }}'
regexp: '^\s*gpgcheck\W.*'
replace: 'gpgcheck=1'
register: status
failed_when: status.rc is defined and status.rc != 257
with_flattened:
loop:
- '/etc/yum.conf'
- '/etc/dnf/dnf.conf'
- '{{ yum_repos.stdout_lines| default([]) }}' # noqa 104
- '/etc/yum/pluginconf.d/rhnplugin.conf'
- name: remove deprecated or insecure packages | package-01 - package-09
+7
View File
@@ -13,6 +13,10 @@
apt:
update_cache: yes
when: ansible_facts.os_family == 'Debian'
- name: install required tools on debian
apt:
name: procps
when: ansible_facts.os_family == 'Debian'
- name: install required tools on fedora
dnf:
name:
@@ -20,6 +24,9 @@
- findutils
- procps-ng
when: ansible_facts.distribution == 'Fedora'
- name: install required tools on SuSE
shell: "zypper -n install python-xml"
when: ansible_facts.os_family == 'Suse'
- name: create recursing symlink to test minimize access
shell: "rm -f /usr/bin/zzz && ln -s /usr/bin /usr/bin/zzz"
vars: