From 17d134172db09b318e766b1bf7c6ae4b3180a7c3 Mon Sep 17 00:00:00 2001 From: Ahmad Wilson Date: Tue, 30 Sep 2025 10:14:40 -0500 Subject: [PATCH] fix: ansible lint fixes --- .github/workflows/CI.yaml | 6 +++--- tasks/common/custom-facts.yml | 6 +++--- tasks/common/download-binary.yml | 14 +++++++------- tasks/common/network-setup.yml | 2 +- tests/ansible-lint.yml | 2 +- tests/molecule/container-basic/molecule.yml | 12 ++++++++++++ tests/molecule/container-full/molecule.yml | 12 ++++++++++++ tests/molecule/container-uninstall/molecule.yml | 2 ++ tests/molecule/systemd-basic/molecule.yml | 12 ++++++++++++ tests/molecule/systemd-full/molecule.yml | 12 ++++++++++++ tests/molecule/systemd-uninstall/molecule.yml | 5 +++++ 11 files changed, 70 insertions(+), 15 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 0191b74..b7fdb0d 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -15,7 +15,7 @@ jobs: - name: Lint yaml and Ansible configs run: | python -m pip install --upgrade pip - pip install ansible-lint==24.12.2 yamllint==1.35.1 + pip install ansible-core==2.16.3 ansible-lint==24.12.2 yamllint==1.35.1 yamllint --config-file ./tests/yaml-lint.yml . ansible-lint --config-file ./tests/ansible-lint.yml . molecule: @@ -37,12 +37,12 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.13" + python-version: "3.12" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install molecule-docker pytest-testinfra ansible + pip install molecule==25.9.0 molecule-docker==2.1.0 pytest-testinfra==10.2.2 ansible-core==2.16.3 - name: Start Docker run: | diff --git a/tasks/common/custom-facts.yml b/tasks/common/custom-facts.yml index 57cc231..0a239cd 100644 --- a/tasks/common/custom-facts.yml +++ b/tasks/common/custom-facts.yml @@ -2,7 +2,7 @@ # --- Common --- - name: Set fact for config file directories - set_fact: + ansible.builtin.set_fact: _config_file_directories: >- {{ _config_file_directories | default([]) + @@ -18,7 +18,7 @@ label: "{{ item.key }}" - name: Set fact for data_dirs hostPaths - set_fact: + ansible.builtin.set_fact: _data_dirs_hostpaths: >- {{ _data_dirs_hostpaths | default([]) + @@ -34,7 +34,7 @@ loop: "{{ ports | dict2items }}" when: item.value.ingressPort is defined -- name: Ensure ingress_list {{ _ingress_list }} contains valid port numbers +- name: Ensure ingress_list contains valid port numbers {{ _ingress_list }} ansible.builtin.set_fact: _ingress_list: "{{ _ingress_list | select('match', '^[0-9]+$') | list }}" diff --git a/tasks/common/download-binary.yml b/tasks/common/download-binary.yml index add345c..4fab5f4 100644 --- a/tasks/common/download-binary.yml +++ b/tasks/common/download-binary.yml @@ -1,5 +1,5 @@ --- -- name: Ensure destination directory [{{ destination_directory }}] exists +- name: Ensure destination directory exists {{ destination_directory }} ansible.builtin.file: path: "{{ destination_directory }}" state: directory @@ -11,15 +11,15 @@ binary_file_path: "/tmp/{{ binary_url | basename }}" target_binary_path: "{{ destination_directory }}/{{ binary_file_name_override | default(binary_url | basename) }}" -- name: Download the binary file from [{{ binary_url }}] to [{{ binary_file_path }}] +- name: Download binary file {{ binary_url }} ansible.builtin.get_url: url: "{{ binary_url }}" dest: "{{ binary_file_path }}" mode: "0755" -- name: Handle binary file [{{ binary_file_name }}] based on type +- name: Handle binary file based on type {{ binary_file_name }} block: - - name: Extract archive [{{ binary_file_name }}] to [{{ destination_directory }}] + - name: Extract archive {{ binary_file_name }} ansible.builtin.unarchive: src: "{{ binary_file_path }}" dest: "{{ destination_directory }}" @@ -28,21 +28,21 @@ - "--strip-components={{ binary_strip_components }}" when: binary_file_name | regex_search('\.(tar|tar\.gz|tgz|zip)$') - - name: Move binary file [{{ binary_file_name }}] to [{{ target_binary_path }}] + - name: Move binary file {{ binary_file_name }} ansible.builtin.command: > mv {{ binary_file_path }} {{ target_binary_path }} register: mv_output changed_when: mv_output.rc != 0 when: not (binary_file_name | regex_search('\.(tar|tar\.gz|tgz|zip)$')) -- name: Check if the binary override file [{{ binary_file_name_override }}] exists at [{{ destination_directory }}] +- name: Check if binary override file exists {{ binary_file_name_override }} ansible.builtin.stat: path: "{{ destination_directory }}/{{ binary_file_name_override }}" register: binary_override_file_stat when: - binary_file_name_override is defined -- name: Fail if override binary file [{{ binary_file_name_override }}] is missing at [{{ destination_directory }}] +- name: Fail if override binary file is missing {{ binary_file_name_override }} ansible.builtin.fail: msg: "The binary file does not exist at {{ destination_directory }}/{{ binary_file_name_override }}." when: diff --git a/tasks/common/network-setup.yml b/tasks/common/network-setup.yml index 77568c1..d25fc45 100644 --- a/tasks/common/network-setup.yml +++ b/tasks/common/network-setup.yml @@ -1,5 +1,5 @@ --- -- name: Allow service ingress ports {{ _ingress_list }} in iptables setup +- name: Allow service ingress ports in iptables setup {{ _ingress_list }} ansible.builtin.iptables: chain: INPUT protocol: tcp diff --git a/tests/ansible-lint.yml b/tests/ansible-lint.yml index f2233df..5f64cc5 100644 --- a/tests/ansible-lint.yml +++ b/tests/ansible-lint.yml @@ -4,6 +4,6 @@ exclude_paths: - ../.git/ - ../.github - ../helm/ - - ./* + - .ansible/ warn_list: - experimental diff --git a/tests/molecule/container-basic/molecule.yml b/tests/molecule/container-basic/molecule.yml index e3b14d4..37c3617 100644 --- a/tests/molecule/container-basic/molecule.yml +++ b/tests/molecule/container-basic/molecule.yml @@ -21,3 +21,15 @@ verifier: directory: ./tests scenario: name: container-basic + test_sequence: + - dependency + - cleanup + - destroy + - create + - prepare + - converge + - idempotence + - side_effect + - verify + - cleanup + - destroy diff --git a/tests/molecule/container-full/molecule.yml b/tests/molecule/container-full/molecule.yml index 488969e..3ec4d25 100644 --- a/tests/molecule/container-full/molecule.yml +++ b/tests/molecule/container-full/molecule.yml @@ -22,3 +22,15 @@ verifier: directory: ./tests scenario: name: container-full + test_sequence: + - dependency + - cleanup + - destroy + - create + - prepare + - converge + - idempotence + - side_effect + - verify + - cleanup + - destroy diff --git a/tests/molecule/container-uninstall/molecule.yml b/tests/molecule/container-uninstall/molecule.yml index f17b900..2eac507 100644 --- a/tests/molecule/container-uninstall/molecule.yml +++ b/tests/molecule/container-uninstall/molecule.yml @@ -24,6 +24,8 @@ scenario: name: container-uninstall test_sequence: - dependency + - cleanup + - destroy - create - prepare - converge diff --git a/tests/molecule/systemd-basic/molecule.yml b/tests/molecule/systemd-basic/molecule.yml index d8f98ab..59df960 100644 --- a/tests/molecule/systemd-basic/molecule.yml +++ b/tests/molecule/systemd-basic/molecule.yml @@ -26,3 +26,15 @@ verifier: directory: ./tests scenario: name: systemd-basic + test_sequence: + - dependency + - cleanup + - destroy + - create + - prepare + - converge + - idempotence + - side_effect + - verify + - cleanup + - destroy diff --git a/tests/molecule/systemd-full/molecule.yml b/tests/molecule/systemd-full/molecule.yml index e3ce5ca..b38a352 100644 --- a/tests/molecule/systemd-full/molecule.yml +++ b/tests/molecule/systemd-full/molecule.yml @@ -26,3 +26,15 @@ verifier: directory: ./tests scenario: name: systemd-full + test_sequence: + - dependency + - cleanup + - destroy + - create + - prepare + - converge + - idempotence + - side_effect + - verify + - cleanup + - destroy diff --git a/tests/molecule/systemd-uninstall/molecule.yml b/tests/molecule/systemd-uninstall/molecule.yml index e23929b..7939f13 100644 --- a/tests/molecule/systemd-uninstall/molecule.yml +++ b/tests/molecule/systemd-uninstall/molecule.yml @@ -28,8 +28,13 @@ scenario: name: systemd-uninstall test_sequence: - dependency + - cleanup + - destroy - create - prepare - converge + - idempotence + - side_effect - verify + - cleanup - destroy