feat: edit molecule test to make it more comprehensive
Some checks failed
test / Linting (push) Successful in 10s
test / Molecule tests (default, debian11) (push) Successful in 41s
test / Molecule tests (default, debian12) (push) Successful in 42s
test / Molecule tests (default, ubuntu2004) (push) Successful in 48s
test / Molecule tests (default, ubuntu2204) (push) Successful in 47s
test / Molecule tests (with_custom_packages, debian11) (push) Failing after 46s
test / Molecule tests (with_custom_packages, debian12) (push) Failing after 45s
test / Molecule tests (with_custom_packages, ubuntu2004) (push) Failing after 1m1s
test / Molecule tests (with_custom_packages, ubuntu2204) (push) Failing after 56s

This commit is contained in:
Bertrand Lanson 2023-11-29 21:55:24 +01:00
parent ad106d8648
commit 0a265c1135
4 changed files with 86 additions and 44 deletions

View File

@ -19,6 +19,9 @@
- stat_etc_hosts.stat.gr_name == 'root' - stat_etc_hosts.stat.gr_name == 'root'
- name: "Test: packages pip, vault-cli, yamllint, docker" - 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: block:
- name: "Get pip3 up-to-date packages" - name: "Get pip3 up-to-date packages"
ansible.builtin.command: "pip3 list -u --format=json" ansible.builtin.command: "pip3 list -u --format=json"
@ -30,17 +33,22 @@
changed_when: false changed_when: false
register: pip_outdated_packages 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" - name: "Verify packages pip, vault-cli, yamllint, docker"
vars:
pip_up_to_date_list: "{{ pip_updated_packages.stdout | from_json | json_query('[].name') }}"
pip_out_of_date_list: "{{ pip_outdated_packages.stdout | from_json | json_query('[].name') }}"
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- "'pip' in pip_up_to_date_list" - "'pip' in pip3_updated_list"
- "'pip' not in pip_out_of_date_list" - "pip3_outdated_list is not defined"
- "'vault-cli' not in pip_up_to_date_list"
- "'vault-cli' not in pip_out_of_date_list" - name: "Print up-to-date packages"
- "'yamllint' not in pip_up_to_date_list" ansible.builtin.debug:
- "'yamllint' not in pip_out_of_date_list" msg: "{{ pip3_updated_list }}"
- "'docker' not in pip_up_to_date_list"
- "'docker' not in pip_out_of_date_list"

View File

@ -23,6 +23,9 @@
- stat_etc_hosts.stat.gr_name == etc_hosts_group[(ansible_distribution|lower)] - stat_etc_hosts.stat.gr_name == etc_hosts_group[(ansible_distribution|lower)]
- name: "Test: packages pip, vault-cli, yamllint, docker" - 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: block:
- name: "Get pip3 up-to-date packages" - name: "Get pip3 up-to-date packages"
ansible.builtin.command: "pip3 list -u --format=json" ansible.builtin.command: "pip3 list -u --format=json"
@ -34,17 +37,22 @@
changed_when: false changed_when: false
register: pip_outdated_packages 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" - name: "Verify packages pip, vault-cli, yamllint, docker"
vars:
pip_up_to_date_list: "{{ pip_updated_packages.stdout | from_json | json_query('[].name') }}"
pip_out_of_date_list: "{{ pip_outdated_packages.stdout | from_json | json_query('[].name') }}"
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- "'pip' in pip_up_to_date_list" - "'pip' in pip3_updated_list"
- "'pip' not in pip_out_of_date_list" - "pip3_outdated_list is not defined"
- "'vault-cli' not in pip_up_to_date_list"
- "'vault-cli' not in pip_out_of_date_list" - name: "Print up-to-date packages"
- "'yamllint' not in pip_up_to_date_list" ansible.builtin.debug:
- "'yamllint' not in pip_out_of_date_list" msg: "{{ pip3_updated_list }}"
- "'docker' not in pip_up_to_date_list"
- "'docker' not in pip_out_of_date_list"

View File

@ -19,6 +19,9 @@
- stat_etc_hosts.stat.gr_name == 'root' - stat_etc_hosts.stat.gr_name == 'root'
- name: "Test: packages pip, vault-cli, yamllint, docker" - 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: block:
- name: "Get pip3 up-to-date packages" - name: "Get pip3 up-to-date packages"
ansible.builtin.command: "pip3 list -u --format=json" ansible.builtin.command: "pip3 list -u --format=json"
@ -30,17 +33,22 @@
changed_when: false changed_when: false
register: pip_outdated_packages 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" - name: "Verify packages pip, vault-cli, yamllint, docker"
vars:
pip_up_to_date_list: "{{ pip_updated_packages.stdout | from_json | json_query('[].name') }}"
pip_out_of_date_list: "{{ pip_outdated_packages.stdout | from_json | json_query('[].name') }}"
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- "'pip' in pip_up_to_date_list" - "'pip' in pip3_updated_list"
- "'pip' not in pip_out_of_date_list" - "not pip3_outdated_list"
- "'vault-cli' not in pip_up_to_date_list"
- "'vault-cli' in pip_out_of_date_list" - name: "Print up-to-date packages"
- "'yamllint' not in pip_up_to_date_list" ansible.builtin.debug:
- "'yamllint' in pip_out_of_date_list" msg: "{{ pip3_updated_list }}"
- "'docker' in pip_up_to_date_list"
- "'docker' not in pip_out_of_date_list"

View File

@ -23,6 +23,9 @@
- stat_etc_hosts.stat.gr_name == etc_hosts_group[(ansible_distribution|lower)] - stat_etc_hosts.stat.gr_name == etc_hosts_group[(ansible_distribution|lower)]
- name: "Test: packages pip, vault-cli, yamllint, docker" - 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: block:
- name: "Get pip3 up-to-date packages" - name: "Get pip3 up-to-date packages"
ansible.builtin.command: "pip3 list -u --format=json" ansible.builtin.command: "pip3 list -u --format=json"
@ -34,17 +37,32 @@
changed_when: false changed_when: false
register: pip_outdated_packages 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" - name: "Verify packages pip, vault-cli, yamllint, docker"
vars:
pip_up_to_date_list: "{{ pip_updated_packages.stdout | from_json | json_query('[].name') }}"
pip_out_of_date_list: "{{ pip_outdated_packages.stdout | from_json | json_query('[].name') }}"
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- "'pip' in pip_up_to_date_list" - "'pip' in pip3_updated_list"
- "'pip' not in pip_out_of_date_list" - "'pip' not in pip3_outdated_list"
- "'vault-cli' not in pip_up_to_date_list" - "'vault-cli' not in pip3_updated_list"
- "'vault-cli' in pip_out_of_date_list" - "'vault-cli' in pip3_outdated_list"
- "'yamllint' not in pip_up_to_date_list" - "'yamllint' not in pip3_updated_list"
- "'yamllint' in pip_out_of_date_list" - "'yamllint' in pip3_outdated_list"
- "'docker' in pip_up_to_date_list" - "'docker' in pip3_updated_list"
- "'docker' not in pip_out_of_date_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 }}"