From 5225493ca0485fcdae25fcc0ae947c7ab3aadecc Mon Sep 17 00:00:00 2001 From: Simon Leiner Date: Sat, 24 Sep 2022 06:28:21 +0200 Subject: [PATCH] CI: Fix linting job for ansible-lint 6.6.0 (#96) * CI: Fix linting job for ansible-lint 6.6.0 * Increase MetalLB timeout to mitigate CI flakiness --- .github/workflows/lint.yml | 17 ++++++++++++++--- .../from_outside/tasks/test/deploy-example.yml | 4 ++++ .../from_outside/tasks/test/get-nodes.yml | 4 ++++ requirements.txt | 2 ++ roles/k3s/master/tasks/main.yml | 11 +++++++++-- roles/k3s/post/defaults/main.yml | 2 +- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 546e4a8..b1a46c3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,10 +18,21 @@ jobs: - name: Set up Python 3.x uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 #4.0.2 with: - python-version: '3.x' + python-version: "3.x" - - name: Install test dependencies - run: pip3 install yamllint ansible-lint ansible + - name: Install dependencies + run: | + echo "::group::Upgrade pip" + python3 -m pip install --upgrade pip + echo "::endgroup::" + + echo "::group::Install Python requirements from requirements.txt" + python3 -m pip install -r requirements.txt + echo "::endgroup::" + + echo "::group::Install Ansible role requirements from collections/requirements.yml" + ansible-galaxy install -r collections/requirements.yml + echo "::endgroup::" - name: Run yamllint run: yamllint . diff --git a/molecule/resources/verify/from_outside/tasks/test/deploy-example.yml b/molecule/resources/verify/from_outside/tasks/test/deploy-example.yml index d150c44..9248be7 100644 --- a/molecule/resources/verify/from_outside/tasks/test/deploy-example.yml +++ b/molecule/resources/verify/from_outside/tasks/test/deploy-example.yml @@ -43,6 +43,10 @@ {{ nginx_services.resources[0].status.loadBalancer.ingress[0].ip }} port: >- {{ nginx_services.resources[0].spec.ports[0].port }} + # Deactivated linter rules: + # - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap + # would be undefined. This will not be the case during playbook execution. + # noqa jinja[invalid] always: - name: "Remove namespace: {{ testing_namespace }}" diff --git a/molecule/resources/verify/from_outside/tasks/test/get-nodes.yml b/molecule/resources/verify/from_outside/tasks/test/get-nodes.yml index aa7df6b..a10ba36 100644 --- a/molecule/resources/verify/from_outside/tasks/test/get-nodes.yml +++ b/molecule/resources/verify/from_outside/tasks/test/get-nodes.yml @@ -22,3 +22,7 @@ | unique | sort }} + # Deactivated linter rules: + # - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap + # would be undefined. This will not be the case during playbook execution. + # noqa jinja[invalid] diff --git a/requirements.txt b/requirements.txt index 9fe5fcb..9ef698c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ ansible-core>=2.13.2 +ansible-lint>=6.6.0 jmespath jsonpatch kubernetes>=12.0.0 @@ -6,3 +7,4 @@ molecule-vagrant>=1.0.0 molecule>=4.0.1 netaddr>=0.8.0 pyyaml>=3.11 +yamllint>=1.28.0 diff --git a/roles/k3s/master/tasks/main.yml b/roles/k3s/master/tasks/main.yml index dc43bce..6a40a98 100644 --- a/roles/k3s/master/tasks/main.yml +++ b/roles/k3s/master/tasks/main.yml @@ -153,12 +153,19 @@ owner: "{{ ansible_user }}" mode: "u=rw,g=,o=" -- name: Configure kubectl cluster to https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 +- name: Configure kubectl cluster to {{ endpoint_url }} command: >- k3s kubectl config set-cluster default - --server=https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 + --server={{ endpoint_url }} --kubeconfig ~{{ ansible_user }}/.kube/config changed_when: true + vars: + endpoint_url: >- + https://{{ apiserver_endpoint | ansible.utils.ipwrap }}:6443 + # Deactivated linter rules: + # - jinja[invalid]: As of version 6.6.0, ansible-lint complains that the input to ipwrap + # would be undefined. This will not be the case during playbook execution. + # noqa jinja[invalid] - name: Create kubectl symlink file: diff --git a/roles/k3s/post/defaults/main.yml b/roles/k3s/post/defaults/main.yml index 5753b81..a20f9cf 100644 --- a/roles/k3s/post/defaults/main.yml +++ b/roles/k3s/post/defaults/main.yml @@ -1,3 +1,3 @@ --- # Timeout to wait for MetalLB services to come up -metal_lb_available_timeout: 60s +metal_lb_available_timeout: 120s