2023-08-23 21:27:16 +00:00
|
|
|
---
|
|
|
|
- name: Verify
|
|
|
|
hosts: all
|
|
|
|
gather_facts: false
|
|
|
|
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'
|
|
|
|
|
2023-08-24 19:55:43 +00:00
|
|
|
- name: "Test: packages pip, vault-cli, yamllint, ansible-core"
|
2023-08-23 21:27:16 +00:00
|
|
|
block:
|
2023-08-24 19:55:43 +00:00
|
|
|
- name: "Get pipx installed packages"
|
|
|
|
ansible.builtin.command: "pipx list --json"
|
2023-08-24 21:23:51 +00:00
|
|
|
environment:
|
|
|
|
PIPX_HOME: "/opt/pipx"
|
2023-08-23 21:27:16 +00:00
|
|
|
changed_when: false
|
2023-08-24 19:55:43 +00:00
|
|
|
register: pipx_installed_packages
|
2023-08-23 21:27:16 +00:00
|
|
|
|
2023-08-24 19:55:43 +00:00
|
|
|
- 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 }}"
|
2023-08-23 21:27:16 +00:00
|
|
|
|
2023-08-24 19:55:43 +00:00
|
|
|
- name: "Verify packages pip, vault-cli, yamllint, ansible-core"
|
2023-08-23 21:27:16 +00:00
|
|
|
ansible.builtin.assert:
|
|
|
|
that:
|
2023-08-24 19:55:43 +00:00
|
|
|
- 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 }}"
|