Commit Graph

34 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 6007645fd7 Refactor use of include_vars
Use a first_found lookup instead of a with_first_found loop so that
the 'paths' parameter can be used.

This ensures that only vars from the role are included, and not vars
from a parent calling role. This can happen when a parent role has
a higher priority vars file available for inclusion than the role
it calls.

Change-Id: I078590020a98f0b5759f3de524753e01bb9c5597
2022-01-12 08:52:34 +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
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
Mohammed Naser b792753b34 cleanup: use updated conditionals
This role made use of conditionals that still used filters, this
patch removes them all and switches them to the new system.

Change-Id: I7c68f4e5f7248aedd3cdae734aac6d97a8ce058b
2019-01-07 12:56:12 -05: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
Major Hayden 2d407a5399
Add scaffolding for contrib tasks
This patch adds the basic scaffolding for developer-contributed
hardening standards that are outside the scope of the Security
Technical Implementation Guide (STIG). Deployers have the option
to deploy these hardening standards as well.

Change-Id: I33175ffd36a75d27e5ac6c13aaf1584e5fdf23dd
2017-11-08 07:28:47 -06: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 5ef94bf0ca
Fix security role gate
This commit removes the verbose options from the gate job and disables
clamav installation in the CI jobs. The clamav package is only available
in the EPEL repository, but the EPEL repo has been removed from
the CentOS images in the OpenStack gate. This will need to be handled
carefully in a later patch.

It also removes an apostrophe from `tasks/main.yml` that breaks syntax
highlighting in vim.

Change-Id: Ifbfc56ed5fe92887cf5beb6b2703fdc3e1c8bb05
2017-05-16 10:24:25 -05:00
Jean-Philippe Evrard 9361a146e4 Do not update grub if grub not used
The security check should be skipped if GRUB update tool does not
exist (grub isn't installed).

Change-Id: I99a3b372e12e264cbc40bdc3ae6b6b60bf3c1c79
2017-04-13 12:34:22 +00:00
Jesse Pretorius 78d844a008 Rename vars/common.yml to vars/main.yml
The file vars/main.yml is automatically loaded
so by using this file name we're able to get
rid of the task that loads vars/common.yml which
is a small optimisation.

Change-Id: I4e0a1b81c42a90b7cd28830f1c2e72c7bd62efaf
2017-03-13 18:30:43 +00:00
Major Hayden 12dd05b0a8 Install EPEL for security role
The security role needs to install packages from EPEL.

Closes-bug: 1670798
Change-Id: Ia6a6ba19ec164e852b83492f4992f25e8df49308
2017-03-07 21:20:30 +00:00
Major Hayden 87b635e0b0 Always check for EFI
This patch ensures that the EFI check always runs. This fixes a bug
where the role fails when a tag is provided to the role at runtime.

Closes-bug: 1660391
Change-Id: I2cba58343910ec7e9b43e88ae26bec3b056eff81
2017-01-30 11:09:24 -06:00
Major Hayden 280e797a4e Set grub2 password [+Docs]
This patch allows deployers to optionally set a GRUB 2 password for accessing
single-user and maintenance runlevels. Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I33d1ef4dec72d196deaca142169675aa5077740b
2016-12-08 16:20:23 -06:00
Major Hayden 4c792445d4 Move common variables to common.yml
This patch creates a common.yml variables file to hold variables
that apply to all distributions supported by the role. It also adds
comments into the existing vars file to instruct developers and
deployers about the proper location for variables.

Implements: blueprint security-rhel7-stig
Change-Id: Idad1cbfe0c6992a6333c4740080764a3ac776628
2016-11-20 17:11:12 +00:00
Major Hayden 53ffc83901 Use dynamic includes for speedup
Now that Ansible 2.x allows for dynamic includes, we can drive a hard
split between the RHEL 6 and RHEL 7 STIG work. This speeds up gate jobs
and avoids situations where a variable is defined in one STIG playbook
versus another.

Implements: blueprint security-rhel7-stig
Change-Id: If3cf9f2154055a316c0764556d57a0dde9e061f4
2016-11-18 16:38:04 -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 235ee0604a Use ansible_service_mgr fact
This patch removes some extra tasks for detecting systemd and uses
the `ansible_service_mgr` fact instead.

Partial-Bug: #1640125
Change-Id: I240f2b09f123fb929eaca07fec72e981901d7a78
2016-11-10 07:25:13 +00:00
Major Hayden a3e0f681d8 Remove deprecated always_run
The `always_run` argument has been deprecated[1] and replaced with
`check_mode: no`.

[1] http://docs.ansible.com/ansible/playbooks_checkmode.html

Change-Id: I534fbcdfe5212822f510de8fd06bd7d7337299fa
2016-11-09 11:42:30 -06:00
Major Hayden 90c363031e Use centralised Ansible test scripts
This patch consumes the centralised Ansible test scripts
implemented in https://review.openstack.org/381853

Depends-On: I5c1f2f0949d6b7ad7bfc4151257b081728ba956f
Depends-On: Ie379de765c6ebba958ce8e7f9dc27b7a3af74ff8
Change-Id: Ib7fe11b666322b11b1e30dea775304fd5d236f2f
2016-10-10 08:56:20 -05: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
Jesse Pretorius 481ad31683 Force Ansible to use dynamic includes
Ansible 2.1.1 introduces a regression in the way conditional
includes are handled which results in every task in the
included file being evaluated even if the condition for the
include is not met. This extends the run time significantly
for a deployment.

This patch forces all conditional includes to be dynamic.

Change-Id: I638b9e20176e0205a378704150e88d098b925c83
Related-Bug: https://github.com/ansible/ansible/issues/17687
2016-09-22 16:00:43 +01:00
Major Hayden 578ce32998 Ensure AIDE initializes on subsequent runs
If a deployer installs AIDE the first time they apply the role
without initializing AIDE and they want to initialize it later,
the handler that does the initialization never fires.

This patch does a few things:

  - Ensures AIDE initialization if the initialize_aide bool is True
  - Doesn't intialize the AIDE db if it already exists
  - Moves the new db into place on Red Hat systems
  - Moves the AIDE tasks into its own file with tags
  - Prevents AIDE from trawling through /var

Closes-bug: 1616281

Change-Id: I85d65738fde064b06b1147c529b22c3f44a33e94
2016-08-25 12:56:35 +00:00
Jenkins fbd64ccc66 Merge "Correct tags attribute typo" 2016-08-06 14:45:38 +00:00
Jimmy McCrory 08bd55d317 Correct tags attribute typo
A couple of include tasks had 'tags' mistyped as 'tag'.

This also resolves a 'Specifying include variables at the top-level of
the task is deprecated.' deprecation warning seen in Ansible 2.1.1.0.

Change-Id: I1a806238e918fdae06da2b412399d812d644f467
2016-08-05 17:28:28 -07:00
Major Hayden fa11dd430b
Add idempotency check
This patch adds idempotency checking for the security role. It
ensures that no changes are made when the security role runs
multiple times against the same system.

Change-Id: Ia5df45ddc64b1af5149df64f3483f472b06d73f7
2016-07-22 10:52:49 -05:00
Major Hayden ba256815a3
Use standard check for systemd
This patch brings the security role in-line with other OSA roles in
the method they use to check for systemd.

Change-Id: Id84d0c606a0323e4357d227d50e29dea1af2949d
2016-06-14 07:44:51 -05:00
Major Hayden d8ae1e3b04 Set check_mode variable every time
In check mode, the security role will fail when tags are used. This
is because the check_mode variable wasn't being set when tags were
provided. This patch ensures that the tasks that check for check mode
and set the subsequent check_mode variable will run every time.

Closes-bug: 1590086

Change-Id: Ib6a29ee4c36632cd6d982ce87105f0ddec4a891d
2016-06-07 13:05:49 -05:00
Jean-Philippe Evrard ecb0329088 Consistency for multi-os in the includes
This makes the include_vars consistent accross all the
openstack-ansible-.* repos.

Change-Id: I6156a4c6c128131eb84a2da897cc853a9037a7c4
2016-06-02 13:47:57 +00:00
Major Hayden 7b313ee1bc Adding audit rule for SELinux policy modifications
This patch fixes the auditd rules template so that AppArmor and SELinux
policy modifications are logged, depending on which Linux distribution
is in use. The security_audit_apparmor_changes variable has been renamed
to security_audit_mac_changes to be more generic.

Documentation updates and a release note are included.

Closes-bug: 1584187

Change-Id: I0955e2cb8a05af4afd36aaca518322a9df6d1ff7
2016-05-27 13:28:02 +00:00
Major Hayden 31424a42af Enable LSM instead of checking status
This patch enables the appropriate Linux Security Module (LSM) for the system
rather than simply checking it. This brings the role more in line with the
STIG requirements and allows it to be used as a more generic role in other
non-OpenStack-Ansible deployments.

It shouldn't affect OpenStack-Ansible deployments since AppArmor is expected
to be running in those deployments.

Documentation and release notes are included.

Change-Id: Ia017f12be0d60ea74b54396bc8278e4db92295ba
2016-05-26 09:16:42 -05:00
Major Hayden 22c4c21583 Add CentOS 7 and Ubuntu 16.04 support
This patch adds initial support for CentOS 7 and Ubuntu 16.04
to the security role. Documentation and tests still need updates
in subsequent patches.

Release notes are included.

Change-Id: Iae936bb307a5938651c55e703d68d39a7716d178
2016-05-13 14:57:28 -05:00
Major Hayden 3e2e66db63 Check mode compatibility for security role
Closes-bug: 1516142

Implements: blueprint security-hardening

Change-Id: Ia38fbdd8bd8fa5aaef1252569563bf0a829f095d
2015-12-02 20:50:33 +00:00
Jesse Pretorius 58ac7a8a7a Enable role testing and make structure ansible-galaxy compatible
This patch adds the bits needed to implement automated syntax/lint
role testing. It also moves the role into the base repository so
that the role becomes fully compatible with ansible-galaxy to
improve the role's consumability.

Change-Id: Ia79cd5dedbbe50dfdf46688830a989ff0897832a
2015-10-09 11:47:23 +00:00