manage_pip_packages/molecule/default/verify.yml

41 lines
1.6 KiB
YAML
Raw Normal View History

---
- name: Verify
hosts: all
2023-12-03 16:50:24 +00:00
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"
- "pip3_outdated_list is not defined"
- name: "Print up-to-date packages"
ansible.builtin.debug:
msg: "{{ pip3_updated_list }}"