Commit Graph

31 Commits

Author SHA1 Message Date
Dmitriy Rabotyagov db5c6f2d66 Fix linters and metadata
With update of ansible-lint to version >=6.0.0 a lot of new
linters were added, that enabled by default. In order to comply
with linter rules we're applying changes to the role.

With that we also update metdata to reflect current state.

Change-Id: I1920cd05ac5b4d32ad12bce42d9161a568f288b6
2023-07-17 14:25:21 +02:00
Jonathan Rosser 480dd9d866 Remove references to unsupported operating systems
All references to Gentoo, SUSE, Debian stretch and Centos-7  are removed.
Conditional tasks, ternary operators and variables are simplified where possible
OS specific variables files are generalised where possible
Change-Id: Id3136a5eed068e317aa1a7b33a1149629dc76d77
2021-06-11 14:14:20 +00:00
Jonathan Rosser b9a9310d7c Use ansible_facts[] instead of fact variables
See https://github.com/ansible/ansible/issues/73654

Change-Id: I3dc2486a0666367d673b23403f2510c94c40eaf4
2021-03-10 16:54:58 +00:00
Dmitriy Rabotyagov 180fc448eb Make possible to avoid aide installation
This patch adds variable `security_rhel7_enable_aide`. When it's False,
all AIDE related tasks would be ommited.

Change-Id: I64af348d9f49922ab51d8cd348d987df4263faa1
2021-02-02 14:12:10 +00:00
Jonathan Rosser c6703cd5e5 Fix linter errors
Work around the mutually incompatible W503 and W504.

Change-Id: I45d0ca8a911d9cf1af2df52a1cf911db817b13b3
2021-02-02 16:11:03 +02:00
Jesse Pretorius f381cc02af Switch to using import_tasks for static inclusion
Using dynamic inclusion (include_tasks) should only be done
if the tasks to include are based on a conditional and there
is no expectation for the tag on the include task to be applied
to all included tasks. Using include_tasks for static inclusion
dramatically raises memory consumption. Using include_tasks also
breaks the ability to use a tag applied to the include.

In this patch we fix all inclusions to ensure that they are set
properly to dynamic or static inclusions where necessary.

We also remove the unnecessary leading whitespace in the main
task file.

Change-Id: Idff86d4a90d3309f0e9ae3b9f0559b37e25dc26f
Closes-Bug: #1800169
2019-01-08 11:54:21 +00:00
Major Hayden 74c904247f
Use import/include_tasks
This patch uses the new import_tasks/include_tasks modules from
Ansible 2.1+ and removes some deprecation warnings from the
beginning of playbook runs.

Change-Id: I17d0a9bcb9964d666e140b832b6f2a26ff948d41
2018-01-18 10:03:25 -06:00
Jenkins 096fcd4c13 Merge "Allow epel-release package name customization" 2017-07-12 18:43:55 +00:00
Jenkins 3fe83a0d24 Merge "Conditionally install EPEL if needed" 2017-07-12 18:41:48 +00:00
Major Hayden bcce655e08 Allow epel-release package name customization
This patch allows deployers to provide a custom name/URL for the
traditional epel-release package.

Related-bug: 1702167
Change-Id: Ie5e30776d2d25a8c254f88c16e17ea15aa38ef26
2017-07-12 18:14:58 +00:00
Major Hayden a64c833a71 Conditionally install EPEL if needed
The current behavior of the hardening role is to install the
epel-release package on all deployments. This patch changes
the logic to only install the EPEL repository if the deployer
has asked for ClamAV to be installed.

The patch also provides an option to disable the installation
of EPEL entirely using a variable.

Closes-Bug: 1702167
Change-Id: I9c5e6048f95636faf2a6d71ac9217ba69ca41296
2017-07-12 15:40:33 +00:00
Major Hayden 6ae8823bc1 Split long running tasks
This patch moves two of the longer-running tasks into their own tasks
file with async enabled.

Change-Id: Idd2d6f2afcfb2c74fa011c0e81d4712cb8c8a2dc
2017-07-03 16:43:45 +00:00
Markos Chandras f422da8599 Add support for the openSUSE Leap distributions
Add support for the openSUSE Leap distributions. The security rules
are similar to the RedHat and Ubuntu ones. We also replace
ansible_os_family with ansible_pkg_mgr since the former does not
return consistent results across different SUSE distributions especially
on older Ansible versions.

Change-Id: I20ffe17039bb641aad70d8123f0b7e7417a42cba
2017-06-27 15:43:53 +01:00
Major Hayden 6c9c7fad66 Get a list of all users + interactive users
This patch adjusts main.yml to retrieve a list of all users and a
list of just interactive users using the get_users module.

Change-Id: I4ff3ceeb068e339c62456f2e5c62ec97b72751f4
2017-06-13 06:32:17 +00:00
Major Hayden 97186f8339 Initial Fedora 25 support
This patch adds the initial support for Fedora 25 in the security
role. A non-voting gate job is proposed in the following review:

  https://review.openstack.org/#/c/467297/

Docs and general cleanup for Fedora/Debian support is coming soon.

Change-Id: Ia6c551d2f33255f7f71f7ba9bb328fc8f17f61e0
2017-05-31 13:33:34 +00:00
Major Hayden 6e761efc9c
Move tasks to 'accounts' file
Several tasks in the auth.yml file were actually more closely related
to accounts rather than authentication. This patch moves tasks from
the auth.yml into accounts.yml and adjusts the docs to match.

This should alleviate confusion and allow deployers to fine-tune
their Ansible playbook runs.

Change-Id: I962014ba9022dd256dc04da6b4ac0860797fbc24
2017-05-20 13:37:16 -05:00
Major Hayden 4a23bc88ff Use async for RPM verification
This patch runs the RPM verification asynchronously to speed up the
playbook run.

Change-Id: I7e114031cf81f89b6134614ebcff62edc5fafc65
2017-02-12 17:47:18 +00:00
Major Hayden 505a4a9eb0 Enable AIDE [+Docs]
This patch installs AIDE and optionally initializes the AIDE database. A
cron job is also deployed for CentOS/RHEL since it doesn't come with
the AIDE package itself.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: Iae04c95903960deee2d750037c08b50c4ce4f800
2016-12-08 16:20:23 -06:00
Major Hayden e06fc8726f Ensure prep tasks have 'always' tag
Some of the prep tasks for the RHEL 7 content did not have the 'always' tag,
which caused playbooks to fail when using a tag, like 'auth'.

Closes-Bug: 1646934
Change-Id: I651b5ee964e916b9d7add1d1d5f9dbb139eb6be3
2016-12-02 13:11:47 -06:00
Major Hayden 3efe849be8 Enable SELinux/AppArmor [+Docs]
This patch enables SELinux/AppArmor and sets the SELinux targeted policy
on CentOS/RHEL hosts. Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I7e225bc10331e12d2405154d873a578e18532305
2016-11-29 15:42:16 -06:00
Major Hayden 746816cc96 Securing sysctl configurations
This patch adds tasks to secure various network-related settings
via sysctl. Documentation will be in a follow-on patch.

Controls implemented:

  - RHEL-07-040350
  - RHEL-07-040351
  - RHEL-07-040380
  - RHEL-07-040410
  - RHEL-07-040420
  - RHEL-07-040421
  - RHEL-07-040730
  - RHEL-07-040860

Implements: blueprint security-rhel7-stig
Change-Id: I35f82165ccb2ea0e17ea32030968b7f33b1a073a
2016-11-16 09:58:17 -06:00
Major Hayden 3c0cc41969 Enable virus scanner
The STIG requires that a virus scanner is installed and running. This
won't be popular on many hypervisors or OpenStack control plane servers,
so the tasks are disabled by default.

Implements: blueprint security-rhel7-stig
Change-Id: I3b4803139e63aae3b740e8e150cb552a298c4ece
2016-11-14 08:23:38 -06:00
Major Hayden 09487fd13d Add template for audit rules
This patch adds audit rules for the following STIG controls:

  - RHEL-07-030492
  - RHEL-07-030510
  - RHEL-07-030511
  - RHEL-07-030512
  - RHEL-07-030513
  - RHEL-07-030514
  - RHEL-07-030521
  - RHEL-07-030522
  - RHEL-07-030523
  - RHEL-07-030524
  - RHEL-07-030525
  - RHEL-07-030526
  - RHEL-07-030530
  - RHEL-07-030531
  - RHEL-07-030540
  - RHEL-07-030541
  - RHEL-07-030550
  - RHEL-07-030560
  - RHEL-07-030561
  - RHEL-07-030630
  - RHEL-07-030670
  - RHEL-07-030671
  - RHEL-07-030672
  - RHEL-07-030673
  - RHEL-07-030674
  - RHEL-07-030750
  - RHEL-07-030751
  - RHEL-07-030752
  - RHEL-07-030753
  - RHEL-07-030754

Implements: blueprint security-rhel7-stig
Change-Id: I538d3013720d107d0a0a83a0bf0d1dea16cf7692
2016-11-10 13:31:01 -06:00
Major Hayden 1f557eb3f7 Fix tags
Each task must be tagged, rather than the include statements. Tasks
get skipped unnecessarily when this is broken.

Change-Id: I7e2850bff4d001f2c57c9d186485f012c547e16a
2016-11-07 21:53:18 +00:00
Major Hayden e5f35284fc Remove packages according to STIG
This patch removes packages per the requirements of these STIGs:

* RHEL-07-040500
* RHEL-07-020010
* RHEL-07-020000
* RHEL-07-021910
* RHEL-07-040560

Implements: blueprint security-rhel7-stig
Change-Id: I52459d54c578c4e14392bf647268a2237f8df24a
2016-11-07 21:47:35 +00:00
Major Hayden e4d3ea4749 Add RHEL-07-010430 and RHEL-07-010431
This patch disables automatic and timed logins in gdm only if gdm
is installed and configured.

Implements: blueprint security-rhel7-stig
Change-Id: I34c1f91deb20441d8ca577f38d44c30c05718205
2016-11-01 18:07:07 +00:00
Major Hayden 0637257c60 Add RHEL-07-010270 (ssh - empty password)
This patch adds the tasks and documentation for RHEL-07-010270.

Implements: blueprint security-rhel7-stig
Change-Id: I6af1d6f188f7244c261c3c847f2056f293023eca
2016-10-31 14:01:15 -05:00
Major Hayden 1a0724d9da Security: Add tasks for RHEL-07-010260
This patch adds tasks to disallow logins from accounts with null
or blank passwords.

Implements: blueprint security-rhel7-stig
Change-Id: Icc5fd167be93bff9946810a17d8ef5521653d648
2016-10-20 15:44:37 +00:00
Major Hayden 0a7a9932a0 Security: Add tasks for RHEL-07-010020
This patch adds tasks which check for files that have been modified
since their packages were installed. This can sometimes be sign
of compromise.

Any files failing checksum validation are displayed for the deployer
to review.

Implements: blueprint security-rhel7-stig
Change-Id: I5ccc375ecb08e51c51dab80b47a190050731f700
2016-10-20 15:44:31 +00:00
Major Hayden 6971f039d7 Security: Add tasks for RHEL-07-010010
This patch adds tasks to check for files which have had their
permissions or ownership modified since they were installed.

To avoid running RPM verification multiple times, the report is
gathered up front one time and then parsed quickly with grep in
subsequent tasks.

Implements: blueprint security-rhel7-stig
Change-Id: I170176319ac6dcda5f736fa90eb4eb47c4ce76b8
2016-10-20 15:44:20 +00:00
Major Hayden d001b9dda5 Initial scaffolding for RHEL 7 STIG
This patch adds the initial scaffolding for the RHEL 7 STIG content
and provides a pathway for adding gate jobs that test the tasks for
the new content.

Implements: blueprint security-rhel7-stig
Change-Id: I4cc9468977fc6c14f4ca792a8964fa7a60a4e831
2016-10-03 16:37:46 +00:00