47 lines
1.7 KiB
YAML
47 lines
1.7 KiB
YAML
|
---
|
||
|
- 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'
|
||
|
|
||
|
- name: "Test: packages pip, vault-cli, yamllint, docker"
|
||
|
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: "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:
|
||
|
that:
|
||
|
- "'pip' in pip_up_to_date_list"
|
||
|
- "'pip' not in pip_out_of_date_list"
|
||
|
- "'vault-cli' not in pip_up_to_date_list"
|
||
|
- "'vault-cli' not in pip_out_of_date_list"
|
||
|
- "'yamllint' not in pip_up_to_date_list"
|
||
|
- "'yamllint' not in pip_out_of_date_list"
|
||
|
- "'docker' not in pip_up_to_date_list"
|
||
|
- "'docker' not in pip_out_of_date_list"
|