Skip to content

Commit d6b1b3a

Browse files
authored
Merge pull request #1104 from stackhpc/feature/2023.1/cis
Enable CIS benchmark hardening in AIO and Multinode
2 parents a2c1d8e + 3763af7 commit d6b1b3a

File tree

11 files changed

+91
-2
lines changed

11 files changed

+91
-2
lines changed

.github/workflows/stackhpc-all-in-one.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,20 @@ jobs:
355355
KAYOBE_AUTOMATION_SSH_PRIVATE_KEY: ${{ steps.ssh_key.outputs.ssh_key }}
356356
if: inputs.upgrade
357357

358+
- name: Ensure we have IP on breth1 to reach the instances
359+
# NOTE(wszumski): Whilst we don't need to create resources again, in some circumstances
360+
# we can lose the IP address that allows us to connect to the instances. This playbook
361+
# also fixes that issue.
362+
run: |
363+
docker run -t --rm \
364+
-v $(pwd):/stack/kayobe-automation-env/src/kayobe-config \
365+
-e KAYOBE_ENVIRONMENT -e KAYOBE_VAULT_PASSWORD -e KAYOBE_AUTOMATION_SSH_PRIVATE_KEY \
366+
${{ steps.kayobe_image.outputs.kayobe_image }} \
367+
/stack/kayobe-automation-env/src/kayobe-config/.automation/pipeline/playbook-run.sh etc/kayobe/ansible/configure-aio-resources.yml
368+
env:
369+
KAYOBE_AUTOMATION_SSH_PRIVATE_KEY: ${{ steps.ssh_key.outputs.ssh_key }}
370+
if: inputs.upgrade
371+
358372
- name: Tempest tests
359373
id: tempest
360374
run: |

doc/source/configuration/security-hardening.rst

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Configuration
1919
--------------
2020

2121
Some overrides to the role defaults are provided in
22-
``$KAYOBE_CONFIG_PATH/inventory/group_vars/overcloud/cis``. These may not be
22+
``$KAYOBE_CONFIG_PATH/inventory/group_vars/cis-hardening/cis``. These may not be
2323
suitable for all deployments and so some fine tuning may be required. For
2424
instance, you may want different rules on a network node compared to a
2525
controller. It is best to consult the upstream role documentation for details
@@ -31,6 +31,14 @@ about what each variable does. The documentation can be found here:
3131
Running the playbooks
3232
---------------------
3333

34+
.. note::
35+
36+
The hosts may need rebooting to fully pick up all of the changes. The CIS
37+
roles will warn you when this needs to be done, but the actual reboot is left
38+
as a manual operation to allow you to select a convenient time. Generally, if
39+
you are applying the hardening for the first time, then you will need to
40+
reboot.
41+
3442
As there is potential for unintended side effects when applying the hardening
3543
playbooks, the playbooks are not currently enabled by default. It is recommended
3644
that they are first applied to a representative staging environment to determine
@@ -40,3 +48,33 @@ whether or not workloads or API requests are affected by any configuration chang
4048
4149
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/cis.yml
4250
51+
Targetting additional hosts
52+
---------------------------
53+
54+
The ``cis.yml`` playbook targets hosts in the ``cis-hardening`` group. By
55+
default this includes the ``overcloud`` group. You can adjust this group
56+
to suit your needs, e.g to add the seed VM:
57+
58+
.. code-block:: yaml
59+
:caption: $KAYOBE_CONFIG_PATH/inventory/groups
60+
61+
[cis-hardening:children]
62+
overcloud
63+
seed
64+
65+
Enabling the host configure hook
66+
--------------------------------
67+
68+
A hook is pre-installed but its execution is guarded by the
69+
``stackhpc_enable_cis_benchmark_hardening_hook`` configuration option.
70+
If you want the hardening playbooks to run automatically, as part of
71+
host configure, simply set this flag to ``true``:
72+
73+
.. code-block:: yaml
74+
:caption: $KAYOBE_CONFIG_PATH/stackhpc.yml
75+
76+
stackhpc_enable_cis_benchmark_hardening_hook: true
77+
78+
Alternatively, this can be toggled on a per-environment basis by
79+
setting it in an environment specific config file, or even on
80+
targeted hosts by using group or host vars.

etc/kayobe/ansible/cis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22

33
- name: Security hardening
4-
hosts: overcloud
4+
hosts: cis-hardening
55
become: true
6+
tags:
7+
- cis
68
tasks:
79
# TODO: Remove this when Red Hat FIPS policy has been updated to allow ed25519 keys.
810
# https://gitlab.com/gitlab-org/gitlab/-/issues/367429#note_1840422075
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
stackhpc_enable_cis_benchmark_hardening_hook: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
3+
stackhpc_enable_cis_benchmark_hardening_hook: true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
3+
- import_playbook: ../../../ansible/cis.yml
4+
when: stackhpc_enable_cis_benchmark_hardening_hook | bool
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
###############################################################################
3+
# Feature flags
4+
5+
# Whether or not to run CIS benchmark hardening playbooks. Default is false.
6+
stackhpc_enable_cis_benchmark_hardening_hook: false

etc/kayobe/inventory/groups

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,9 @@ rgws
125125
[mgrs]
126126
[osds]
127127
[rgws]
128+
129+
###############################################################################
130+
# Feature control groups
131+
132+
[cis-hardening:children]
133+
overcloud

etc/kayobe/stackhpc.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,9 @@ stackhpc_docker_registry: "{{ pulp_url | regex_replace('^https?://', '') }}"
156156
# Username and password of container registry.
157157
stackhpc_docker_registry_username: "{{ pulp_username }}"
158158
stackhpc_docker_registry_password: "{{ pulp_password }}"
159+
160+
###############################################################################
161+
# Feature flags
162+
163+
# Whether or not to run CIS benchmark hardening playbooks. Default is false.
164+
#stackhpc_enable_cis_benchmark_hardening_hook:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
features:
3+
- |
4+
Adds a hook to automatically run the CIS benchmark hardening playbooks as
5+
part of host configure. This is guarded by the
6+
``stackhpc_enable_cis_benchmark_hardening_hook`` configuration option and is
7+
disabled by default.

0 commit comments

Comments
 (0)