Skip to content

Commit 24d4d04

Browse files
authored
Update test environments to current Ansible version (#909)
* Update test environments to current Ansible version Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de> * Add Workaround for vagrant Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de> --------- Signed-off-by: Martin Schurz <Martin.Schurz@telekom.de>
1 parent 95e50cb commit 24d4d04

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

.github/workflows/os_hardening_vm.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ on: # yamllint disable-line rule:truthy
99
- 'molecule/os_hardening_vm/**'
1010
- '.github/workflows/os_hardening_vm.yml'
1111
- 'requirements.txt'
12+
- 'requirements-vm.txt'
1213
pull_request:
1314
branches: [master]
1415
paths:
1516
- 'roles/os_hardening/**'
1617
- 'molecule/os_hardening_vm/**'
1718
- '.github/workflows/os_hardening_vm.yml'
1819
- 'requirements.txt'
20+
- 'requirements-vm.txt'
1921
schedule:
2022
- cron: '0 6 * * 2'
2123

@@ -63,7 +65,7 @@ jobs:
6365
source ~/.venv/ansible-collection-hardening/bin/activate
6466
python -m pip install --no-cache-dir --upgrade pip
6567
pip install -r requirements.txt
66-
pip install python-vagrant
68+
pip install -r requirements-vm.txt
6769
working-directory: ansible_collections/devsec/hardening
6870

6971
- name: Downgrade Ansible for Rocky 8 tests
@@ -84,6 +86,8 @@ jobs:
8486
- name: Test with molecule
8587
run: |
8688
source ~/.venv/ansible-collection-hardening/bin/activate
89+
# Workaround for https://github.com/ansible-community/molecule-plugins/issues/301
90+
export MOLECULE_VAGRANT_PLUGIN_DIR=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')/molecule_plugins/vagrant
8791
molecule test -s os_hardening_vm
8892
env:
8993
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}

.github/workflows/ssh_hardening_bsd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ on: # yamllint disable-line rule:truthy
99
- 'molecule/ssh_hardening_bsd/**'
1010
- '.github/workflows/ssh_hardening_bsd.yml'
1111
- 'requirements.txt'
12+
- 'requirements-vm.txt'
1213
pull_request:
1314
branches: [master]
1415
paths:
1516
- 'roles/ssh_hardening/**'
1617
- 'molecule/ssh_hardening_bsd/**'
1718
- '.github/workflows/ssh_hardening_bsd.yml'
1819
- 'requirements.txt'
20+
- 'requirements-vm.txt'
1921
schedule:
2022
- cron: '0 6 * * 5'
2123

@@ -51,7 +53,7 @@ jobs:
5153
source ~/.venv/ansible-collection-hardening/bin/activate
5254
python -m pip install --no-cache-dir --upgrade pip
5355
pip install -r requirements.txt
54-
pip install python-vagrant
56+
pip install -r requirements-vm.txt
5557
working-directory: ansible_collections/devsec/hardening
5658

5759
- name: Update Vagrant Box
@@ -61,6 +63,8 @@ jobs:
6163
- name: Test with molecule
6264
run: |
6365
source ~/.venv/ansible-collection-hardening/bin/activate
66+
# Workaround for https://github.com/ansible-community/molecule-plugins/issues/301
67+
export MOLECULE_VAGRANT_PLUGIN_DIR=$(python3 -c 'import sysconfig; print(sysconfig.get_paths()["purelib"])')/molecule_plugins/vagrant
6468
molecule test -s ssh_hardening_bsd
6569
env:
6670
MOLECULE_DISTRO: ${{ matrix.molecule_distro }}

molecule/os_hardening_vm/molecule.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ provisioner:
2525
defaults:
2626
interpreter_python: auto_silent
2727
callbacks_enabled: profile_tasks, timer, yaml
28+
# Workaround for https://github.com/ansible-community/molecule-plugins/issues/301
29+
library: "${MOLECULE_PROJECT_DIRECTORY}/plugins/modules:/usr/share/ansible:${MOLECULE_VAGRANT_PLUGIN_DIR}"
2830
verifier:
2931
name: ansible
3032
env:

molecule/shared/prerequisites.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
- name: Make sure environment variable for MOLECULE_DISTRO is set
66
ansible.builtin.assert:
77
that:
8-
- "lookup('env','MOLECULE_DISTRO')"
8+
- "lookup('env','MOLECULE_DISTRO') | length > 0"
99
fail_msg: "You need to set MOLECULE_DISTRO to a supported image name. See CONTRIBUTING.md"

molecule/ssh_hardening_bsd/molecule.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ provisioner:
2121
defaults:
2222
interpreter_python: auto_silent
2323
callbacks_enabled: profile_tasks, timer, yaml
24+
# Workaround for https://github.com/ansible-community/molecule-plugins/issues/301
25+
library: "${MOLECULE_PROJECT_DIRECTORY}/plugins/modules:/usr/share/ansible:${MOLECULE_VAGRANT_PLUGIN_DIR}"
2426
verifier:
2527
name: ansible
2628
env:

requirements-vm.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
molecule-plugins[vagrant]==25.8.12

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
molecule==25.1.0
2-
molecule-plugins[docker]==23.7.0
3-
ansible-core==2.18.6
1+
molecule==25.9.0
2+
molecule-plugins[docker]==25.8.12
3+
ansible-core==2.19.3
44
docker==7.1.0
55
jmespath==1.0.1
66
aar-doc==2.3.0

0 commit comments

Comments
 (0)