manage_pip_packages/molecule/with_custom_packages/verify.yml
Bertrand Lanson 879f0f11fe
All checks were successful
test / Linting (push) Successful in 41s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m9s
test / Molecule tests (default, debian11) (push) Successful in 1m32s
test / Molecule tests (default, debian12) (push) Successful in 1m27s
test / Molecule tests (with_custom_packages, debian11) (push) Successful in 48s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m2s
test / Molecule tests (with_custom_packages, debian12) (push) Successful in 54s
test / Molecule tests (with_custom_packages, ubuntu2204) (push) Successful in 54s
test / Molecule tests (with_custom_packages, ubuntu2004) (push) Successful in 1m11s
feat(tests): remove /etc/hosts testing, fix #1
2023-12-08 18:34:45 +01:00

51 lines
2.0 KiB
YAML

---
- name: Verify
hosts: all
gather_facts: true
become: true
tasks:
- name: "Test: packages pip, vault-cli, yamllint, docker"
vars:
wanted_up_to_date_list: ["pip", "docker"]
wanted_out_of_date_list: ["vault-cli", "yamllint"]
block:
- name: "Get pip3 up-to-date packages"
ansible.builtin.command: "pip3 list -u --format=json"
changed_when: false
register: pip_updated_packages
- name: "Get pip3 out-of-date packages"
ansible.builtin.command: "pip3 list -o --format=json"
changed_when: false
register: pip_outdated_packages
- name: "Set fact for pip3 up-to-date packages"
ansible.builtin.set_fact:
pip3_updated_list: "{{ pip3_updated_list | default({}) | combine({item.name: item.version}) }}"
loop: "{{ pip_updated_packages.stdout | from_json | selectattr('name', 'in', wanted_up_to_date_list) | list }}"
- name: "Set fact for pip3 out-of-date packages"
ansible.builtin.set_fact:
pip3_outdated_list: "{{ pip3_outdated_list | default({}) | combine({item.name: item.version}) }}"
loop: "{{ pip_outdated_packages.stdout | from_json | selectattr('name', 'in', wanted_out_of_date_list) | list }}"
- name: "Verify packages pip, vault-cli, yamllint, docker"
ansible.builtin.assert:
that:
- "'pip' in pip3_updated_list"
- "'pip' not in pip3_outdated_list"
- "'vault-cli' not in pip3_updated_list"
- "'vault-cli' in pip3_outdated_list"
- "'yamllint' not in pip3_updated_list"
- "'yamllint' in pip3_outdated_list"
- "'docker' in pip3_updated_list"
- "'docker' not in pip3_outdated_list"
- name: "Print up-to-date packages"
ansible.builtin.debug:
msg: "{{ pip3_updated_list }}"
- name: "Print out-of-date packages"
ansible.builtin.debug:
msg: "{{ pip3_outdated_list }}"