From a7ace2e55b490194e36645c614e6d86bb963bbc8 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Mon, 7 Oct 2024 13:58:04 +0200 Subject: [PATCH 1/3] ansible-lint: Adjust pre-commit hooks dependencies Dropping the ansible dependencies for ansible-lint will allow us to catch missing dependencies collections in galaxy.yml. For collections needed for contrib/ or tests/ (i.e: not part of core kubespray dependencies), we can just configure ansible-lint to mock them. This mean it won't check the mocked module parameters, but for those area of the code base it's an acceptable trade-off. --- .ansible-lint | 2 ++ .pre-commit-config.yaml | 1 - tests/requirements.yml | 3 --- 3 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 tests/requirements.yml diff --git a/.ansible-lint b/.ansible-lint index 75ae44c14..68a403363 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -37,3 +37,5 @@ exclude_paths: - tests/files/custom_cni/cilium.yaml - venv - .github +mock_modules: + - gluster.gluster.gluster_volume diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3592fb258..834040d2e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,6 @@ repos: hooks: - id: ansible-lint additional_dependencies: - - ansible==9.8.0 - jsonschema==4.22.0 - jmespath==1.0.1 - netaddr==1.3.0 diff --git a/tests/requirements.yml b/tests/requirements.yml deleted file mode 100644 index 6eeb070ec..000000000 --- a/tests/requirements.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -collections: - - name: gluster.gluster From 07e551ab7796b6b2fc51c09426cfe97df0ff2d03 Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Mon, 7 Oct 2024 14:15:34 +0200 Subject: [PATCH 2/3] pre-commit: auto-update all hooks --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 834040d2e..d8e3a7f84 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ --- repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -35,7 +35,7 @@ repos: files: "\\.sh$" - repo: https://github.com/ansible/ansible-lint - rev: v24.5.0 + rev: v24.9.2 hooks: - id: ansible-lint additional_dependencies: From 4f27bc2bf92f40168b995f86d6873087a755477b Mon Sep 17 00:00:00 2001 From: Max Gautier Date: Mon, 7 Oct 2024 14:18:36 +0200 Subject: [PATCH 3/3] pre-commit: drop redundant ansible-syntax-check ansible-lint hook already check syntax on the playbooks. --- .pre-commit-config.yaml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8e3a7f84..d3e0ab3b9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,14 +52,6 @@ repos: - repo: local hooks: - - id: ansible-syntax-check - name: ansible-syntax-check - entry: env ANSIBLE_INVENTORY=inventory/local-tests.cfg ANSIBLE_REMOTE_USER=root ANSIBLE_BECOME="true" ANSIBLE_BECOME_USER=root ANSIBLE_VERBOSITY="3" ansible-playbook --syntax-check - language: python - files: "^cluster.yml|^upgrade-cluster.yml|^reset.yml|^extra_playbooks/upgrade-only-k8s.yml" - additional_dependencies: - - ansible==9.5.1 - - id: tox-inventory-builder name: tox-inventory-builder entry: bash -c "cd contrib/inventory_builder && tox"