Skip to content

Commit c5db757

Browse files
Merge branch 'master' into os_immutable_fs
2 parents 8515f82 + d4ca770 commit c5db757

File tree

131 files changed

+4523
-1749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+4523
-1749
lines changed

.aar_doc.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
output_template: |
2+
<!-- BEGIN_ANSIBLE_DOCS -->
3+
4+
## Supported Operating Systems
5+
6+
{%- for platform in metadata.galaxy_info.platforms %}
7+
- {{ platform.name }}
8+
{%- if "versions" in platform %}
9+
- {{ platform.versions | default([]) | join(', ') }}
10+
{%- endif %}
11+
{%- endfor %}
12+
13+
## Role Variables
14+
{% for entrypoint in argument_specs.keys() %}
15+
{%- set path, options=entrypoint_options[entrypoint][0] -%}
16+
{%- for name, details in options.items() |sort() %}
17+
- `{{ name }}`
18+
- Default: `{{ details.display_default }}`
19+
- Description: {{ details.display_description }}
20+
- Type: {{ details.display_type }}
21+
- Required: {{ details.display_required }}
22+
{%- if details.choices %}
23+
- Choices:
24+
{%- for choice in details.choices %}
25+
- {{ choice }}
26+
{%- endfor %}
27+
{%- endif %}
28+
{%- endfor %}
29+
{%- endfor %}
30+
31+
## Dependencies
32+
33+
{%- if ("dependencies" in metadata) and (metadata.dependencies | length > 0) %}
34+
{%- for dependency in metadata.dependencies %}
35+
- {{ dependency }}
36+
{%- endfor %}
37+
{%- else %}
38+
39+
None.
40+
{%- endif %}
41+
42+
## Example Playbook
43+
44+
```
45+
- hosts: all
46+
become: true
47+
roles:
48+
- name: {{ role }}
49+
```
50+
51+
<!-- END_ANSIBLE_DOCS -->

.config/ansible-lint.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@
55
# option will be parsed relative to the CWD of execution.
66
exclude_paths:
77
- .cache/ # implicit unless exclude_paths is defined in config
8-
- .yamllint
9-
- ../molecule/
10-
- ../.github/
8+
- .ansible/ # somehow someone decided that the cache directory should be renamed
9+
# add all waivers individually, since exclude_files does not support globs
10+
- molecule/os_hardening/waivers.yaml
11+
- molecule/ssh_hardening_bsd/waivers_freebsd13.yaml
12+
- molecule/ssh_hardening_bsd/waivers_freebsd14.yaml
13+
- molecule/ssh_hardening_bsd/waivers_openbsd7.yaml
1114

1215
mock_roles:
1316
- geerlingguy.git
1417
- nginxinc.nginx
18+
19+
skip_list:
20+
- var-naming[no-role-prefix]
21+
- meta-runtime[unsupported-version]

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ body:
3131
attributes:
3232
label: "Reproduction steps"
3333
render: Shell
34-
description: Paste an example playbook that can be used to reproduce the problem. This will be automatically formatted into code, so no need for backticks.
34+
description: Paste an example playbook that can be used to reproduce the problem. This will be automatically formatted into code, no need for backticks.
3535
value: |
3636
...
3737
validations:

.github/labeler.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
---
22
mysql_hardening:
3-
- 'roles/mysql_hardening/**'
4-
- 'molecule/mysql_hardening/**'
5-
- '.github/workflows/mysql_hardening.yml'
3+
- changed-files:
4+
- any-glob-to-any-file:
5+
- roles/mysql_hardening/**
6+
- molecule/mysql_hardening/**
7+
- .github/workflows/mysql_hardening.yml
68

79
os_hardening:
8-
- 'roles/os_hardening/**'
9-
- 'molecule/os_hardening/**'
10-
- '.github/workflows/os_hardening.yml'
10+
- changed-files:
11+
- any-glob-to-any-file:
12+
- roles/os_hardening/**
13+
- molecule/os_hardening/**
14+
- .github/workflows/os_hardening.yml
1115

1216
ssh_hardening:
13-
- 'roles/ssh_hardening/**'
14-
- 'molecule/ssh_hardening/**'
15-
- 'molecule/ssh_hardening_custom_tests/**'
16-
- '.github/workflows/ssh_hardening.yml'
17-
- '.github/workflows/ssh_hardening_custom_tests.yml'
17+
- changed-files:
18+
- any-glob-to-any-file:
19+
- roles/ssh_hardening/**
20+
- molecule/ssh_hardening/**
21+
- molecule/ssh_hardening_custom_tests/**
22+
- .github/workflows/ssh_hardening.yml
23+
- .github/workflows/ssh_hardening_custom_tests.yml
1824

1925
nginx_hardening:
20-
- 'roles/nginx_hardening/**'
21-
- 'molecule/nginx_hardening/**'
22-
- '.github/workflows/nginx_hardening.yml'
26+
- changed-files:
27+
- any-glob-to-any-file:
28+
- roles/nginx_hardening/**
29+
- molecule/nginx_hardening/**
30+
- .github/workflows/nginx_hardening.yml

.github/version-drafter.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
major-labels: ['major']
2+
minor-labels: ['minor', 'enhancement']
3+
patch-labels: ['patch', 'bug']

.github/workflows/ansible-lint.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@ on: # yamllint disable-line rule:truthy
77
branches: [master]
88
paths:
99
- 'roles/**'
10+
- 'molecule/**'
11+
- 'requirements.txt'
12+
- '.github/workflows/ansible-lint.yml'
13+
- '.config/ansible-lint.yml'
1014
pull_request:
1115
# The branches below must be a subset of the branches above
1216
branches: [master]
1317
paths:
1418
- 'roles/**'
19+
- 'molecule/**'
20+
- 'requirements.txt'
21+
- '.github/workflows/ansible-lint.yml'
22+
- '.config/ansible-lint.yml'
1523

1624
jobs:
1725
ansible-lint:
18-
runs-on: ubuntu-latest
26+
runs-on: ubuntu-22.04
1927

2028
steps:
21-
# Important: This sets up your GITHUB_WORKSPACE environment variable
22-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2330

2431
- name: Lint Ansible Playbook
25-
# replace "master" with any valid ref
26-
uses: ansible/ansible-lint-action@main
27-
with:
28-
path: "roles/"
32+
uses: ansible/ansible-lint@49ded6a7e4f3acf6b1eb4b3aa2796d84b5faa63a # v25

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
codespell:
1212
uses: "dev-sec/.github/.github/workflows/codespell.yml@main"
1313
with:
14-
ignore_words_list: "chage"
14+
ignore_words_list: "chage,BOOTUP"

.github/workflows/enforce-labels.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ name: "Enforce PR labels"
44
on: # yamllint disable-line rule:truthy
55
pull_request_target:
66
types: [labeled, unlabeled, opened, edited, synchronize]
7+
8+
permissions:
9+
contents: read # to read configuration file
10+
pull-requests: write # to label PRs
11+
712
jobs:
813
enforce-label:
914
if: github.repository == 'dev-sec/ansible-collection-hardening'
10-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-22.04
1116
steps:
12-
- uses: actions/labeler@main
17+
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
1318
with:
1419
repo-token: "${{ secrets.GITHUB_TOKEN }}"
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@ name: Publish collection to Ansible Galaxy
44
on: # yamllint disable-line rule:truthy
55
release:
66
types:
7-
- published
7+
- released
88

99
jobs:
1010
deploy:
1111
if: github.repository == 'dev-sec/ansible-collection-hardening'
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-22.04
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1515

1616
# deploy the collection first, because if it fails, we don't want
1717
# to update the galaxy.yml
1818
- name: Deploy the collection
19-
uses: artis3n/ansible_galaxy_collection@v2
19+
uses: artis3n/ansible_galaxy_collection@f6110aef877db4caaa7e9a192975fb006dea61fe # v2
2020
with:
2121
api_key: ${{ secrets.GALAXY_API_KEY }}
2222
galaxy_version: ${{ github.event.release.tag_name }}
2323

2424
# checkout master instead of the release-tag so we can push the galaxy.yml
25-
- uses: actions/checkout@v3
25+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2626
with:
2727
ref: master
2828

2929
- name: update galaxy.yml with new version
30-
uses: microsoft/variable-substitution@v1
30+
uses: microsoft/variable-substitution@6287962da9e5b6e68778dc51e840caa03ca84495 # v1
3131
with:
3232
files: 'galaxy.yml'
3333
env:
3434
version: "${{ github.event.release.tag_name }}"
3535

3636
- name: push galaxy.yml
37-
uses: github-actions-x/[email protected]
37+
uses: github-actions-x/commit@722d56b8968bf00ced78407bbe2ead81062d8baa # v2.9
3838
with:
3939
github-token: ${{ secrets.GITHUB_TOKEN }}
4040
push-branch: 'master'

.github/workflows/mysql_hardening.yml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ on: # yamllint disable-line rule:truthy
99
- 'roles/mysql_hardening/**'
1010
- 'molecule/mysql_hardening/**'
1111
- '.github/workflows/mysql_hardening.yml'
12+
- 'requirements.txt'
1213
pull_request:
1314
branches: [master]
1415
paths:
1516
- 'roles/mysql_hardening/**'
1617
- 'molecule/mysql_hardening/**'
1718
- '.github/workflows/mysql_hardening.yml'
19+
- 'requirements.txt'
1820
schedule:
1921
- cron: '0 6 * * 0'
2022

@@ -27,46 +29,47 @@ concurrency:
2729

2830
jobs:
2931
build:
30-
runs-on: ubuntu-latest
32+
runs-on: ubuntu-22.04
3133
env:
3234
PY_COLORS: 1
3335
ANSIBLE_FORCE_COLOR: 1
3436
strategy:
3537
fail-fast: false
3638
matrix:
3739
molecule_distro:
38-
- centos7
39-
- centosstream8
4040
- centosstream9
4141
- rocky8
4242
- rocky9
43-
- ubuntu1804
4443
- ubuntu2004
4544
- ubuntu2204
46-
- debian10
45+
- ubuntu2404
4746
- debian11
47+
- debian12
4848
# - amazon # geerlingguy.mysql does not support fedora
4949
# - arch # geerlingguy.mysql does not support arch
5050
- opensuse_tumbleweed
5151
# - fedora # geerlingguy.mysql does not support fedora
5252
steps:
5353
- name: Checkout repo
54-
uses: actions/checkout@v3
54+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
5555
with:
5656
path: ansible_collections/devsec/hardening
5757
submodules: true
5858

59-
- name: Set up Python 3.11
60-
uses: actions/setup-python@v4
59+
- name: Set up Python
60+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
6161
with:
62-
python-version: 3.11
62+
python-version: 3.12
63+
cache: 'pip'
6364

6465
- name: Install dependencies
65-
run: |
66-
sudo apt install git
67-
python -m pip install --no-cache-dir --upgrade pip
68-
pip install -r requirements.txt
66+
run: pip install -r requirements.txt
67+
working-directory: ansible_collections/devsec/hardening
68+
69+
- name: Downgrade Ansible for Rocky 8 tests
70+
run: pip install "ansible-core<2.17"
6971
working-directory: ansible_collections/devsec/hardening
72+
if: matrix.molecule_distro == 'rocky8'
7073

7174
# that was a hard one to fix. robert did it thankfully
7275
# https://github.com/robertdebock/ansible-role-mysql/commit/7562e99099b06282391ab7ed102b393a0406d212
@@ -78,10 +81,19 @@ jobs:
7881
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
7982
if: ${{ startsWith(matrix.molecule_distro, 'Debian') }}
8083

81-
- name: Test with molecule
84+
# Molecule has problems detecting the proper location for installing roles
85+
# https://github.com/ansible/molecule/issues/3806
86+
# we do not set a custom role path, but the automatically determined install path used is not compatible with the location molecule expects the role
87+
# see CI logs of this action "INFO Set ANSIBLE_ROLES_PATH" should not be present, since we do not set a custom path
88+
# we have to find a proper way to configure this
89+
- name: Temporary fix for roles
8290
run: |
83-
molecule --version
84-
molecule test -s mysql_hardening
91+
mkdir -p /home/runner/.ansible
92+
ln -s /home/runner/work/ansible-collection-hardening/ansible-collection-hardening/ansible_collections/devsec/hardening/roles \
93+
/home/runner/.ansible/roles
94+
95+
- name: Test with molecule
96+
run: molecule test -s mysql_hardening
8597
env:
8698
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}
8799
working-directory: ansible_collections/devsec/hardening

0 commit comments

Comments
 (0)