Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exclude_paths:
- .github/
- .markdownlint.yaml
- examples/roles/
- .collection/
mock_roles:
- linux-system-roles.trustee_server
supported_ansible_also:
Expand Down
68 changes: 22 additions & 46 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ jobs:
!((github.event_name == 'pull_request' && contains(github.event.pull_request.title, '[citest_skip]')) ||
(github.event_name == 'push' && contains(github.event.head_commit.message, '[citest_skip]')))
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# There should be one version which is the one used by the Automation Hub gating, and
# one for the latest version.
# https://github.com/ansible-collections/partner-certification-checker/blob/main/.github/workflows/certification-reusable.yml#L108
versions:
- { ansible_lint: "24.*", ansible: "2.16.*", python: "3.12" }
- { ansible_lint: "26.*", ansible: "2.20.*", python: "3.13" }
steps:
- name: Update pip, git
run: |
Expand All @@ -35,53 +44,20 @@ jobs:
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.1"

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.versions.python }}

- name: Convert role to collection format
id: collection
run: |
set -euxo pipefail
TOXENV=collection lsr_ci_runtox
coll_dir=".tox/ansible_collections/$LSR_ROLE2COLL_NAMESPACE/$LSR_ROLE2COLL_NAME"
# cleanup after collection conversion
rm -rf "$coll_dir/.ansible" .tox/ansible-plugin-scan "$coll_dir/.collection"
# ansible-lint action requires a .git directory???
# https://github.com/ansible/ansible-lint/blob/main/action.yml#L45
mkdir -p "$coll_dir/.git"
meta_req_file="${{ github.workspace }}/meta/collection-requirements.yml"
test_req_file="${{ github.workspace }}/tests/collection-requirements.yml"
if [ -f "$meta_req_file" ] && [ -f "$test_req_file" ]; then
coll_req_file="${{ github.workspace }}/req.yml"
python -c 'import sys; import yaml
hsh1 = yaml.safe_load(open(sys.argv[1]))
hsh2 = yaml.safe_load(open(sys.argv[2]))
coll = {}
for item in hsh1["collections"] + hsh2["collections"]:
if isinstance(item, dict):
name = item["name"]
rec = item
else:
name = item # assume string
rec = {"name": name}
if name not in coll:
coll[name] = rec
hsh1["collections"] = list(coll.values())
yaml.safe_dump(hsh1, open(sys.argv[3], "w"))' "$meta_req_file" "$test_req_file" "$coll_req_file"
echo merged "$coll_req_file"
cat "$coll_req_file"
elif [ -f "$meta_req_file" ]; then
coll_req_file="$meta_req_file"
elif [ -f "$test_req_file" ]; then
coll_req_file="$test_req_file"
else
coll_req_file=""
fi
echo "coll_req_file=$coll_req_file" >> $GITHUB_OUTPUT
run: tox -e collection

- name: Run ansible-lint
uses: ansible/ansible-lint@v26
with:
working_directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
requirements_file: ${{ steps.collection.outputs.coll_req_file }}
env:
ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}/.tox
run: |
set -euxo pipefail
LSR_ANSIBLE_LINT_DEP="ansible-lint==${{ matrix.versions.ansible_lint }}" \
LSR_ANSIBLE_LINT_ANSIBLE_DEP="ansible-core==${{ matrix.versions.ansible }}" \
tox -x testenv:ansible-lint-collection.basepython="python${{ matrix.versions.python }}" \
-e ansible-lint-collection
2 changes: 1 addition & 1 deletion .github/workflows/ansible-managed-var-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.1"

- name: Run ansible-plugin-scan
run: |
Expand Down
31 changes: 22 additions & 9 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ jobs:
!((github.event_name == 'pull_request' && contains(github.event.pull_request.title, '[citest_skip]')) ||
(github.event_name == 'push' && contains(github.event.head_commit.message, '[citest_skip]')))
runs-on: ubuntu-latest
strategy:
fail-fast: false # get all results, not just the first failure
matrix:
versions:
- { ansible: "2-14", python: "3.9" }
- { ansible: "2-16", python: "3.11" }
- { ansible: "2-17", python: "3.12" }
- { ansible: "2-18", python: "3.12" }
- { ansible: "2-19", python: "3.13" }
- { ansible: "2-20", python: "3.13" }
- { ansible: "milestone", python: "3.13" }
steps:
- name: Update pip, git
run: |
Expand All @@ -36,16 +47,18 @@ jobs:
- name: Install tox, tox-lsr
run: |
set -euxo pipefail
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.1"

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.versions.python }}

- name: Convert role to collection format
run: |
set -euxo pipefail
TOXENV=collection lsr_ci_runtox
run: tox -e collection

- name: Run ansible-test
uses: ansible-community/ansible-test-gh-action@release/v1
with:
testing-type: sanity # wokeignore:rule=sanity
ansible-core-version: stable-2.17
collection-src-directory: ${{ github.workspace }}/.tox/ansible_collections/${{ env.LSR_ROLE2COLL_NAMESPACE }}/${{ env.LSR_ROLE2COLL_NAME }}
run: |
tox \
-x testenv:ansible-test-${{ matrix.versions.ansible }}.basepython="python${{ matrix.versions.python }}" \
-e ansible-test-${{ matrix.versions.ansible }}
2 changes: 1 addition & 1 deletion .github/workflows/qemu-kvm-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:
python3 -m pip install --upgrade pip
sudo apt update
sudo apt install -y --no-install-recommends git ansible-core genisoimage qemu-system-x86
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.17.1"
pip3 install "git+https://github.com/linux-system-roles/tox-lsr@3.18.1"

# HACK: Drop this when moving this workflow to 26.04 LTS
- name: Update podman to 5.x for compatibility with bootc-image-builder's podman 5
Expand Down
3 changes: 3 additions & 0 deletions plans/test_playbooks_parallel.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ prepare:
if grep -q 'CentOS Linux release 7.9' /etc/redhat-release; then
sed -i '/^mirror/d;s/#\?\(baseurl=http:\/\/\)mirror/\1vault/' /etc/yum.repos.d/*.repo
fi
- name: Ensure use of devel site for yum repos
script: |
sed -i -e 's|\.lab\.bos\.|.devel.|g' -e 's|\.eng\.bos\.|.devel.|g' /etc/yum.repos.d/*.repo
discover:
- name: Prepare managed node
how: fmf
Expand Down
38 changes: 38 additions & 0 deletions tests/tasks/run_role_with_clear_facts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# DO NOT EDIT THIS FILE - managed by linux-system-roles/.github
# Task file: clear_facts, run linux-system-roles.trustee_server.
# Include this with include_tasks or import_tasks
# Input:
# - __sr_tasks_from: tasks_from to run - same as tasks_from in include_role
# - __sr_public: export private vars from role - same as public in include_role
# - __sr_failed_when: set to false to ignore role errors - same as failed_when in include_role
- name: Clear facts
meta: clear_facts

# note that you can use failed_when with import_role but not with include_role
# so this simulates the __sr_failed_when false case
# Q: Why do we need a separate task to run the role normally? Why not just
# run the role in the block and rethrow the error in the rescue block?
# A: Because you cannot rethrow the error in exactly the same way as the role does.
# It might be possible to exactly reconstruct ansible_failed_result but it's not worth the effort.
- name: Run the role with __sr_failed_when false
when:
- __sr_failed_when is defined
- not __sr_failed_when
block:
- name: Run the role
include_role:
name: linux-system-roles.trustee_server
tasks_from: "{{ __sr_tasks_from | default('main') }}"
public: "{{ __sr_public | default(false) }}"
rescue:
- name: Ignore the failure when __sr_failed_when is false
debug:
msg: Ignoring failure when __sr_failed_when is false

- name: Run the role normally
include_role:
name: linux-system-roles.trustee_server
tasks_from: "{{ __sr_tasks_from | default('main') }}"
public: "{{ __sr_public | default(false) }}"
when: __sr_failed_when | d(true)
6 changes: 3 additions & 3 deletions tests/tests_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
hosts: all
tasks:
- name: Include trustee_server role
ansible.builtin.include_role:
name: linux-system-roles.trustee_server
public: true
ansible.builtin.include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Gather package facts
ansible.builtin.package_facts:
Expand Down
1 change: 0 additions & 1 deletion tests/tests_include_vars_from_parent.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
- name: Test role include variable override
hosts: all
gather_facts: true
tasks:
- name: Create var file in caller that can override the one in called role
delegate_to: localhost
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_secret_registration_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
trustee_server_secret_registration_enabled: true
tasks:
- name: Include trustee_server role
ansible.builtin.include_role:
name: linux-system-roles.trustee_server
public: true
ansible.builtin.include_tasks: tasks/run_role_with_clear_facts.yml
vars:
__sr_public: true

- name: Gather package facts
ansible.builtin.package_facts:
Expand Down
2 changes: 1 addition & 1 deletion tests/vars/rh_distros_vars.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# vars for handling conditionals for RedHat and clones
# DO NOT EDIT - file is auto-generated
# repo is https://github.com/linux-system-roles/.github
# file is playbooks/trustee_server/tests/vars/rh_distros_vars.yml
# file is playbooks/templates/tests/vars/rh_distros_vars.yml
---
# Ansible distribution identifiers that the role treats like RHEL
__trustee_server_rh_distros:
Expand Down
Loading