manage_pipx_packages/molecule/with_custom_packages/verify.yml
Bertrand Lanson f189113ebf
All checks were successful
test / Linting (push) Successful in 23s
test / Molecule tests (default, debian12) (push) Successful in 2m4s
test / Molecule tests (default, ubuntu2204) (push) Successful in 2m33s
test / Molecule tests (with_custom_packages, ubuntu2204) (push) Successful in 1m54s
test / Molecule tests (with_custom_packages, debian12) (push) Successful in 4m59s
feat: remove become from role
2023-12-03 17:52:13 +01:00

46 lines
1.6 KiB
YAML

---
- name: Verify
hosts: all
gather_facts: true
become: true
tasks:
- name: "Test: file /etc/hosts"
block:
- name: "Stat file /etc/hosts"
ansible.builtin.stat:
path: "/etc/hosts"
register: stat_etc_hosts
- name: "Verify file /etc/hosts"
ansible.builtin.assert:
that:
- stat_etc_hosts.stat.exists
- stat_etc_hosts.stat.isreg
- stat_etc_hosts.stat.pw_name == 'root'
- stat_etc_hosts.stat.gr_name == 'root'
- name: "Test: packages pip, vault-cli, yamllint, ansible-core"
block:
- name: "Get pipx installed packages"
ansible.builtin.command: "pipx list --json"
environment:
PIPX_HOME: "/opt/pipx"
changed_when: false
register: pipx_installed_packages
- name: "Set fact"
ansible.builtin.set_fact:
pipx_simple_list: "{{ pipx_simple_list | default({}) | combine({item.key: item.value.metadata.main_package.package_version}) }}"
loop: "{{ pipx_installed_packages.stdout | from_json | json_query('venvs') | dict2items }}"
- name: "Verify packages pip, vault-cli, yamllint, ansible-core"
ansible.builtin.assert:
that:
- pipx_simple_list['yamllint'] is defined
- pipx_simple_list['ansible-core'] is defined
- pipx_simple_list['vault-cli'] is defined
- name: "Print installed packages"
ansible.builtin.debug:
msg: "{{ pipx_simple_list }}"