2023-11-29 18:33:18 +00:00
|
|
|
---
|
|
|
|
- name: Verify
|
|
|
|
hosts: all
|
|
|
|
gather_facts: true
|
2023-12-03 16:50:24 +00:00
|
|
|
become: true
|
2023-11-29 18:33:18 +00:00
|
|
|
tasks:
|
|
|
|
- name: "Test: packages pip, vault-cli, yamllint, docker"
|
2023-11-29 20:55:24 +00:00
|
|
|
vars:
|
|
|
|
wanted_up_to_date_list: ["pip", "docker"]
|
|
|
|
wanted_out_of_date_list: ["vault-cli", "yamllint"]
|
2023-11-29 18:33:18 +00:00
|
|
|
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
|
|
|
|
|
2023-11-29 20:55:24 +00:00
|
|
|
- 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 }}"
|
|
|
|
|
2023-11-29 18:33:18 +00:00
|
|
|
- name: "Verify packages pip, vault-cli, yamllint, docker"
|
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
2023-11-29 20:55:24 +00:00
|
|
|
- "'pip' in pip3_updated_list"
|
|
|
|
- "pip3_outdated_list is not defined"
|
|
|
|
|
|
|
|
- name: "Print up-to-date packages"
|
|
|
|
ansible.builtin.debug:
|
|
|
|
msg: "{{ pip3_updated_list }}"
|