From da27eccbc252d9340044b7f06c258a9d198074a5 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Thu, 4 Dec 2025 13:36:53 +0400 Subject: [PATCH 01/14] Add CI environment configuration --- ci/conda.yml | 11 +++++++++++ ci/requirements.ci.txt | 6 ++++++ ci/requirements.txt | 1 + 3 files changed, 18 insertions(+) create mode 100644 ci/conda.yml create mode 100644 ci/requirements.ci.txt create mode 100644 ci/requirements.txt diff --git a/ci/conda.yml b/ci/conda.yml new file mode 100644 index 0000000..75b3c2f --- /dev/null +++ b/ci/conda.yml @@ -0,0 +1,11 @@ +--- +name: ansible-mount-device +channels: + - conda-forge +dependencies: + - python~=3.12 + - pip>=22.2 + - actionlint + - pip: + - -r requirements.txt + - -r requirements.ci.txt diff --git a/ci/requirements.ci.txt b/ci/requirements.ci.txt new file mode 100644 index 0000000..f99c76a --- /dev/null +++ b/ci/requirements.ci.txt @@ -0,0 +1,6 @@ +ansible-lint +molecule==24.12.0 +molecule-plugins[docker] +docker~=7.1.0 +requests==2.31.0 # pinned to the latest version not breaking Docker SDK +yamllint diff --git a/ci/requirements.txt b/ci/requirements.txt new file mode 100644 index 0000000..456b2b7 --- /dev/null +++ b/ci/requirements.txt @@ -0,0 +1 @@ +ansible-core==2.18.11 From af7e4e75049029e31c193ff63c2714f9533e833e Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Thu, 4 Dec 2025 13:50:54 +0400 Subject: [PATCH 02/14] Add a linting workflow --- .ansible-lint | 9 ++++++++ .github/workflows/linters.yml | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .ansible-lint create mode 100644 .github/workflows/linters.yml diff --git a/.ansible-lint b/.ansible-lint new file mode 100644 index 0000000..43cae14 --- /dev/null +++ b/.ansible-lint @@ -0,0 +1,9 @@ +--- +profile: production +strict: true + +# Enable checking of loop variable prefixes in roles +loop_var_prefix: "^(__|{role}_)" + +exclude_paths: + - .github/ diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000..7c3eaad --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,41 @@ +--- +name: linters + +on: + pull_request: + branches: [ "master" ] + push: + branches: [ "master" ] + +jobs: + + ansible-lint: + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - uses: actions/checkout@v5 + + + - uses: mamba-org/setup-micromamba@7f29b8b80078b1b601dfa018b0f7425c587c63bb + with: + micromamba-version: '2.4.0-0' + environment-file: ci/conda.yml + init-shell: bash + post-cleanup: 'all' + + # - name: "Install role dependencies" + # run: ansible-galaxy install -r requirements.yml + # shell: micromamba-shell {0} + + - name: Check workflow files themselves with ActionLint + run: actionlint + shell: micromamba-shell {0} + + - name: Check environment files with YAMLLint + run: yamllint ci/*.yml + shell: micromamba-shell {0} + + - name: Run ansible-lint + run: ansible-lint -c .ansible-lint + shell: micromamba-shell {0} From 7072c0c560f81084e417722334af377d1e171863 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 10:12:16 +0400 Subject: [PATCH 03/14] Update CI environment configuration --- ci/conda.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/conda.yml b/ci/conda.yml index 75b3c2f..68df58c 100644 --- a/ci/conda.yml +++ b/ci/conda.yml @@ -1,10 +1,10 @@ --- -name: ansible-mount-device +name: genlab.common channels: - conda-forge dependencies: - - python~=3.12 - - pip>=22.2 + - python~=3.13.10 + - pip==25.3 - actionlint - pip: - -r requirements.txt From 64743599ec2ead49dbf663c67e3d223c0132ff89 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 10:19:45 +0400 Subject: [PATCH 04/14] lint: Add a changelog.yml stub --- changelog.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog.yml diff --git a/changelog.yml b/changelog.yml new file mode 100644 index 0000000..52e7f38 --- /dev/null +++ b/changelog.yml @@ -0,0 +1,2 @@ +--- +releases: {} From 8c48469441a6dd26b5373175512ec880234cac90 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 10:20:44 +0400 Subject: [PATCH 05/14] lint: Add required Galaxy tags --- galaxy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/galaxy.yml b/galaxy.yml index 9e284de..66c7b7e 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -9,6 +9,8 @@ description: >- The genlab.common collection includes roles for performing deploying and configuring common infrastructural components license_file: LICENSE tags: + - linux + - infrastructure - genlab repository: https://github.com/corvus-migratorius/genlab.common issues: https://github.com/corvus-migratorius/genlab.common/issues From 80d62ca0d6944bebba2322db941d05ef5d81dcbc Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 10:51:41 +0400 Subject: [PATCH 06/14] lint: Restore ariable naming convention --- roles/mount_device/molecule/default/verify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/mount_device/molecule/default/verify.yml b/roles/mount_device/molecule/default/verify.yml index 3538604..ea6fda8 100644 --- a/roles/mount_device/molecule/default/verify.yml +++ b/roles/mount_device/molecule/default/verify.yml @@ -7,12 +7,12 @@ tasks: - name: "Check mountpoint" # noqa: command-instead-of-module changed_when: false - register: mounts + register: mount_device_mounts ansible.builtin.command: cmd: mount -l - name: "Ensure test_file is mounted on test_mount" ansible.builtin.assert: - that: "'/tmp/test_file on /test_mount type ext3' in mounts.stdout" + that: "'/tmp/test_file on /test_mount type ext3' in mount_device_mounts.stdout" success_msg: "/test_mount is a mounted" fail_msg: "/test_mount is not on the list of mounts" From 0d2a340eecd239d36e008ecf6ca0d94c27976db3 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 10:51:52 +0400 Subject: [PATCH 07/14] Drop support for `focal` --- roles/mount_device/meta/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/mount_device/meta/main.yml b/roles/mount_device/meta/main.yml index 5b34d77..b6eded3 100644 --- a/roles/mount_device/meta/main.yml +++ b/roles/mount_device/meta/main.yml @@ -10,7 +10,7 @@ galaxy_info: platforms: - name: "Ubuntu" - versions: [ "focal", "jammy", "noble" ] + versions: ["jammy", "noble"] galaxy_tags: [] From 703be3a159a763c23c336db3785a5e0282d40755 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:15:58 +0400 Subject: [PATCH 08/14] Add a top-level `requirements.yml`, fixing an issues with `posix.mount` --- .github/workflows/linters.yml | 4 ++++ requirements.yml | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 requirements.yml diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 7c3eaad..6ad5b5a 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -36,6 +36,10 @@ jobs: run: yamllint ci/*.yml shell: micromamba-shell {0} + - name: "Install collection dependencies" + run: ansible-galaxy install -r requirements.yml + shell: micromamba-shell {0} + - name: Run ansible-lint run: ansible-lint -c .ansible-lint shell: micromamba-shell {0} diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..a0cd255 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,3 @@ +--- +collections: + - name: ansible.posix From 54bc0341c614ec05eb5c8c0b61e924e92cb9d7f9 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:16:18 +0400 Subject: [PATCH 09/14] lint: Fix another variable naming issue --- roles/mount_device/molecule/default/converge.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/mount_device/molecule/default/converge.yml b/roles/mount_device/molecule/default/converge.yml index af31c05..abb2a3b 100644 --- a/roles/mount_device/molecule/default/converge.yml +++ b/roles/mount_device/molecule/default/converge.yml @@ -5,19 +5,19 @@ pre_tasks: - name: "Check if the disk file already exists" + register: mount_device_disk_file ansible.builtin.stat: path: /tmp/test_file - register: disk_file - name: "Create a file to act as a disk if it doesn't exist" - when: not disk_file.stat.exists + when: not mount_device_disk_file.stat.exists changed_when: false ansible.builtin.shell: | dd if=/dev/zero of=/tmp/test_file bs=1000000 count=100 mkfs.ext3 /tmp/test_file roles: - - role: genlab.mount_device + - role: genlab.common.mount_device devices: - what: "/tmp/test_file" where: "/test_mount" From ce62cc6e903384a6fa0cabe54b166eebb380da92 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:50:39 +0400 Subject: [PATCH 10/14] lint: Replace changelog with a Markdown stub for now --- CHANGELOG.md | 3 +++ changelog.yml | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 changelog.yml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6361e43 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +All notable changes to this project will be documented in this file. diff --git a/changelog.yml b/changelog.yml deleted file mode 100644 index 52e7f38..0000000 --- a/changelog.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -releases: {} From 101a7c80f173d82682854b9ced50384281e65843 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:52:11 +0400 Subject: [PATCH 11/14] Cache micromamba environment --- .github/workflows/linters.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 6ad5b5a..03c44ab 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -23,6 +23,7 @@ jobs: environment-file: ci/conda.yml init-shell: bash post-cleanup: 'all' + cache-environment: true # - name: "Install role dependencies" # run: ansible-galaxy install -r requirements.yml From e62d57b358c72f40c820a3d66ac0a483985f26e5 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:54:46 +0400 Subject: [PATCH 12/14] Add a KICS workflow --- .github/workflows/kics.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/kics.yml diff --git a/.github/workflows/kics.yml b/.github/workflows/kics.yml new file mode 100644 index 0000000..4135c16 --- /dev/null +++ b/.github/workflows/kics.yml @@ -0,0 +1,22 @@ +--- +name: kics + +on: + pull_request: + branches: ["master"] + +jobs: + kics: + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - uses: actions/checkout@v5 + name: Check out source code + + - name: run a KICS scan + uses: checkmarx/kics-github-action@e01759d524f8abd5bd650d3d5bd4b96d46ebbc1d + with: + path: . + token: ${{ secrets.GITHUB_TOKEN }} + output_path: myResults/ From 44600aa700ff2330faf7cea2eaef0476c60ba738 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:57:18 +0400 Subject: [PATCH 13/14] Add CI badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 52eca89..dc6784a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Ansible Collection - genlab.common +[![linters](https://github.com/corvus-migratorius/genlab.common/actions/workflows/linters.yml/badge.svg)](https://github.com/corvus-migratorius/genlab.common/actions/workflows/linters.yml) +[![kics](https://github.com/corvus-migratorius/genlab.common/actions/workflows/kics.yml/badge.svg)](https://github.com/corvus-migratorius/genlab.common/actions/workflows/kics.yml) + ## Roles - [mount_device](roles/mount_device/README.md) From 19d040ca99cdd01359ec0e775ae3be2eb8a800d2 Mon Sep 17 00:00:00 2001 From: Alexander Gorelyshev Date: Fri, 5 Dec 2025 11:57:54 +0400 Subject: [PATCH 14/14] Add a Renovate config --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..5db72dd --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] +}