Commit Graph

81 Commits

Author SHA1 Message Date
Dmitriy Rabotyagov 510a0778a7 Use valid value for CREATE_HOME
At the moment we pass boolean value to CREATE_HOME instead of yes/no.
Leveraging ternary allows to always supply expected values despite of
variable type in ansible.

Closes-Bug: #1850200
Change-Id: I957dc9b98f1de23ea66ea0e225989e4f907a02cb
2024-03-28 10:52:07 +00:00
Dmitriy Rabotyagov b31cd46c18 Disable dynamic motd message
Right now default cloud images of Ubuntu does contain dynamic MOTD
by default, that takes around extra 0.4 sec for establishing connection.

Disabiling MOTD should improve responsivness of hosts and speedup
ansible execution as well.

With that we're keeping static MOTD that has no impact on connection
speed.

Change-Id: Iaf25f6f444055cefd60dd2e3b4d5579f2a6fcdb1
2023-10-26 11:15:46 +00:00
Dmitriy Rabotyagov abfa76ba93 Disable GSSAPIAuthentication for SSH
This implements STIG V-204598 [1] and disables
GSSAPIAuthentication that is enabled by default on EL
systems.
This also should speedup deployments on such systems, as
enabled GSSAPIAuthentication requires some time while
initiating connection.

[1] https://www.stigviewer.com/stig/red_hat_enterprise_linux_7/2020-12-08/finding/V-204598

Change-Id: I2d92541ccfc27e91224fd481c3792993428a052e
2023-10-26 11:15:11 +00:00
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
Dmitriy Rabotyagov aa1feb4527 Clean out SSH options we managing
With current behaviour we duplicate SSH options and don't care if same
thing is defined anywhere down the line.
With that change we change how options are defined - instead of the
template we use a list of mappings. With that
we can select and remove options that playbook supposed to manage.

With that we also keep playbook idempotency. As side effect we still
can have options duplicated but only if they have exact same value.

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-openstack_hosts/+/840353
Change-Id: I140606f7e724fbe2a4f0b03f6a0501da7bdd5964
Closes-Bug: #1958649
2022-05-20 07:53:05 +00:00
Jonathan Rosser 11ae75f92b Add centos-9 support
Change-Id: If86dd75bbf444eaacf9eb7a890f17fa7593a1099
2022-01-06 09:37:04 -05:00
Zuul 4ba0de970a Merge "Explicitly create clamav socket directory" 2021-11-03 12:57:39 +00:00
Dmitriy Rabotyagov 9d6a927d8c Explicitly create clamav socket directory
While most our supported distributions does create LocalSocket on their
own, it's not always the case and shouldn't be trusted that much.

Change-Id: I56851f56aa85108a4898ef99c48ac77c898ccb69
Closes-Bug: #1944564
2021-10-20 15:27:21 +03: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 0114e44f3e Add Centos-8 support
Make hardening compatible with CentOS-8. Dependant patch [1] already
passes hardening and another one resolves issue with installing
non-existent packages. So we should merge this one without passing
CentOS 8 tests not to create circular dependency

[1] https://review.opendev.org/689629

Change-Id: I33160b9a6e8331d6db39824e420033c7ab06780b
2020-05-22 11:03:22 +00:00
Major Hayden a10fae4fe1 Replace Fedora 26 with 27
Now that infra is moving from Fedora 26 to 27, we need to update
the role to reflect the changing support for Fedora releases.

Change-Id: Icce8fd7ee2f8c54e6eb33beec7af96c4d1d375d6
Signed-off-by: Major Hayden <major@mhtx.net>
2018-03-07 13:30:45 +00:00
Markos Chandras 65dce4045a tasks: auth: Pass --unrestricted to Linux Grub2 entries
The password protection aims to only prevent users from editing the
menu entries not from booting the system altogether. Fedora is patching
the 10_linux file to use '--unrestricted' so all users can boot the
system. As such, we apply a similar patch to the rest of the distros.

Change-Id: I1390a330ea1f0b48e71fdcb548614d5582fffbd4
Link: http://pkgs.fedoraproject.org/cgit/rpms/grub2.git/tree/0109-Don-t-require-a-password-to-boot-entries-generated-b.patch
Link: https://www.gnu.org/software/grub/manual/grub/html_node/Authentication-and-authorisation.html#Authentication-and-authorisation
Closes-Bug: 1735709
2018-01-10 16:50:19 +00:00
Yifei Xue 8025799fe6 Fix the path of chrony.keys
The path of chrony.keys on CentOS is different
from the one on Ubuntu. So change the definition
of keyfile to use variable defined in vars.

Change-Id: Ibb54318d5fff452857d917e3b13af6bae26a1b55
Signed-off-by: Yifei Xue <xueyifei@huawei.com>
2017-12-22 10:01:58 +08:00
Markos Chandras a0810a9ca1 tasks: auth: Use standard Grub2 authentication mechanism
GRUB_PASSWORD is not understood by vanilla grub2 installations. As such,
we can use the recommended method by setting the superusers
environment variable and using the password_pbkdf2 command

Change-Id: I07df3decf5e70b85a7dc48b8a8d1ca86e8878d09
Link: https://www.gnu.org/software/grub/manual/grub/grub.html#Security
Closes-Bug: 1735709
2017-12-13 12:38:30 +00: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 782bb48c14
Update to RHEL 7 STIG V1R3
This patch updates the tasks to match the changes in Version 1,
Release 3 of the RHEL 7 STIG. It adds four new configurations:

  - V-77819 (docs only, manual intervention req'd)
  - V-77821 (disabling DCCP, implemented)
  - V-77823 (docs only, manual intervention req'd)
  - V-77825 (enabling ASLR, implemented)

Closes-Bug: 1729344
Change-Id: I009fb31139e654f839d94781baf3d392c6613f46
2017-11-01 13:31:34 -05:00
Major Hayden ba98871f4b
Update to RHEL 7 V1R2 STIG
This patch updates the STIG XML to version 1 release 2.

The new release does not have V-72181 included, so the relevant
tasks and variables have been removed.

Closes-Bug: 1718772
Change-Id: I441dbacdfa82e49c0c24f86e303706ae79c7d4dd
2017-09-21 16:02:42 -05:00
Major Hayden 0c0767b3f1
Queens doc updates + removal of RHEL 6 STIG
This patch begins the teardown of the RHEL 6 STIG content from the
ansible-hardening repository. It will still be maintained in
Pike and earlier branches.

This patch also updates the ansible-hardening documentation for the
Queens release and notes that Pike is the latest stable version.

Closes-Bug: 1715745
Change-Id: Iaae52c97a35d82dd807ef78a1a6593ce3aa33540
2017-09-12 08:19:54 -06:00
Major Hayden b352760fd1
Fedora 26 support
This patch adds support for Fedora 26.

Depends-On: Ic4ea169908fec86623dbe91859ec524e48683ab7
Change-Id: I590bed829d9e3b7a6df477a00b65bfc10fc64dae
2017-08-28 07:33:16 -05:00
Major Hayden f576f24591 Skip sysctl configs when enabled: no
The intended functionality for "enabled: no" on sysctl configurations
was to skip the config entirely and leave the variable unaltered.
However, setting "enabled: no" was causing the configuration to be
removed entirely.

This patch ensures that any sysctl variables with "enabled: no" are
skipped and left unaltered.

Closes-Bug: 1710490
Depends-On: I2607f295a924a2ec51920b5f2b27c34d5222e8ff
Change-Id: If9c8c008538b2ff631a714a8ffe16df9376dedf3
2017-08-22 13:53:39 +00:00
Major Hayden 458e0e4c90
Install libpam-pwquality on Ubuntu
The password quality adjustments only work if libpam-pwquality is
installed on Ubuntu. This patch installs the package if
`security_pwquality_apply_rules` is set to `yes`.

Closes-Bug: 1702526
Change-Id: Ic1a21b12138f57d4d54bfbdc6804a195573baf52
2017-07-12 14:40:05 -05: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 4e9a8a1d6a Initial Debian 8 support
This patch sets up the security role so that it applies cleanly
to systems running Debian 8.

Change-Id: I15f003b8f57922b354143a86ccb34df77759e723
2017-05-23 07:31:18 -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
Major Hayden 701c0b1e32
Fix path to daemon init params file
Ubuntu 14.04 and CentOS 7 have their daemon inititalization
parameters file in different places. This fixes a bug where
the path in CentOS was incorrect.

Closes-Bug: 1662545
Change-Id: Ie0b30848a73f8a1fbc7fe6a475d93d87a72ce40f
2017-04-04 10:52:02 -05:00
Major Hayden dccce1d5cc
Handle RHEL 7 STIG renumbering
This patch gets the docs adjusted to work with the new RHEL 7 STIG
version 1 release. The new STIG release has changed all of the
numbering, but it maintains a link to (most) of the old STIG IDs in
the XML.

Closes-bug: 1676865
Change-Id: I65023fe63163c9804a3aec9dcdbf23c69bedb604
2017-04-04 07:22:12 -05: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 c15d75ecf4 Configure pam_faildelay on Ubuntu
As noted in the bug, Ubuntu 16.04 doesn't use FAIL_DELAY in
`/etc/login.defs` as CentOS 7 does. This patch ensures that
`pam_faildelay` is properly configured on Xenial.

Closes-Bug: 1659120
Change-Id: I9ff9f45c0c5bdd749c9491431e2dcb8836587e78
2017-01-30 13:22:19 -06:00
Logan V dc8dc3dbf9 Install chrony when enabled in RHEL7 STIG
Chrony was not being installed by the RHEL7 STIG package list when
enabled, causing a failure when the service configuration was
attempted.

This fixes the following failure:
http://cdn.pasteraw.com/7vo74lbz1jyf9qm5010mfqa169a8zpf

Change-Id: I6accac5504abe6fb1f2d0d0db5baa9b5a42a5c70
2017-01-21 18:52:09 -06:00
Jenkins 1ed53ab6da Merge "Add Ubuntu audit packages for RHEL 7 STIG" 2017-01-19 15:14:29 +00:00
Matthew Keeler dc949de683 Add Ubuntu audit packages for RHEL 7 STIG
Add auditd and audispd-plugins to Ubuntu's RHEL 7 STIG packages

Change-Id: I34358b80644c513a1f30d796bfcb155c4ded360a
2017-01-16 20:59:53 -06:00
Matthew Keeler cdcfb4680c Fix clamav_service variable to "clamav-daemon"
The ClamAV daemon on Ubuntu is clamav-daemon, rather than clamd.

Change-Id: Ifb04045cd80f236cf41b4b86000561136b631e4a
2017-01-16 20:08:28 -06:00
Major Hayden 1cf9fba0d3 Enable FIPS [+Docs]
This patch installs `dracut-fips` and checks to see if the deployer has FIPS
enabled at boot time. Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I9a6da4dc753fbfc3949f0c78e53af3bb5e3083ef
2016-12-13 18:06:39 +00:00
Jenkins 1dbae8a946 Merge "Check for pam_lastlogin [+Docs]" 2016-12-09 03:51:24 +00:00
Jenkins 66d1cf2cfc Merge "Set action_email_acct in auditd [+Docs]" 2016-12-08 23:04:04 +00:00
Jenkins ba8d9bb7ca Merge "Set space_left_action in auditd [+Docs]" 2016-12-08 23:04:00 +00:00
Jenkins b6a43c6626 Merge "Set space_left in auditd [+Docs]" 2016-12-08 23:03:54 +00:00
Major Hayden 553ad01138 Set action_email_acct in auditd [+Docs]
This patch sets `action_email_acct` to `root` in the auditd configuration.
Deployers can customize the email recipient if needed.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: Ief6e6c8c6c2139e09f1ab9c97594576a5d72701e
2016-12-08 16:23:59 -06:00
Major Hayden 9f3921a650 Set space_left_action in auditd [+Docs]
This patch configures auditd to send emails to the administrator when the
`space_left` threshold is reached. Deployers can customize this setting if
needed.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I93673193b74dacb3def92b761b315eabd41cea41
2016-12-08 16:23:59 -06:00
Major Hayden 42ca47bb41 Set space_left in auditd [+Docs]
This patch sets the `space_left` in the auditd config to 25% of the disk
space on the root disk. Deployers can customize this variable.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I7a91a756fb920decbd1056e7f11f7dd548f2cac8
2016-12-08 16:23:59 -06:00
Major Hayden 28cd87354d Check for pam_lastlogin [+Docs]
This patch adds a verification check for `pam_lastlogin` in PAM's
configuration.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: Ib2135331efc0cfb6dca581ac7c70fac6dc7d3224
2016-12-08 16:20:23 -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 e5db8521d9 Enable automatic package updates [+Docs]
This patch allows a deployer to optionally enable automatic package updates.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I79d38971ea847096e7f20f0912363deaf5028a74
2016-12-08 16:20:23 -06: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 fd4fa2d3d7 Set audisp failure options [+Docs]
This patch adds configurations for audisp when the disk is rull on the remote
server or when there is a network interruption between the local system and
the remote audisp server.

It also explicitly installs auditd/audisp-plugins to ensure that auditd and
the remote audisp log sender are installed on CentOS/RHEL.

Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: I589ae00a70582ee3f5d48453b3c20f23752adfa6
2016-12-08 14:24:03 +00:00
Major Hayden 8ad68162f3 Set minimum password length [+Docs]
This patch allows deployers to opt in for a minimum password
length restriction. Documentation is included.

Implements: blueprint security-rhel7-stig
Change-Id: Ia1d5d6677233ae21ce585b4a363d130e1bb003fa
2016-12-02 19:57:14 +00:00