118 lines
4.3 KiB
YAML
118 lines
4.3 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: service docker"
|
|
block:
|
|
- name: "Get service docker"
|
|
ansible.builtin.service_facts:
|
|
|
|
- name: "Stat file /lib/systemd/system/docker.service"
|
|
ansible.builtin.stat:
|
|
path: "/lib/systemd/system/docker.service"
|
|
register: stat_lib_systemd_system_docker_service
|
|
|
|
- name: "Verify service docker"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- stat_lib_systemd_system_docker_service.stat.exists
|
|
- stat_lib_systemd_system_docker_service.stat.isreg
|
|
- stat_lib_systemd_system_docker_service.stat.pw_name == 'root'
|
|
- stat_lib_systemd_system_docker_service.stat.gr_name == 'root'
|
|
- stat_lib_systemd_system_docker_service.stat.mode == '0644'
|
|
- ansible_facts.services['docker.service'] is defined
|
|
- ansible_facts.services['docker.service']['source'] == 'systemd'
|
|
- ansible_facts.services['docker.service']['state'] == 'running'
|
|
- ansible_facts.services['docker.service']['status'] == 'enabled'
|
|
|
|
- name: "Test: file /etc/docker/daemon.json"
|
|
block:
|
|
- name: "Stat directory /etc/docker"
|
|
ansible.builtin.stat:
|
|
path: "/etc/docker"
|
|
register: stat_etc_docker
|
|
|
|
- name: "Stat file /etc/docker/daemon.json"
|
|
ansible.builtin.stat:
|
|
path: "/etc/docker/daemon.json"
|
|
register: stat_etc_docker_docker_json
|
|
|
|
- name: "Slurp file /etc/docker/daemon.json"
|
|
ansible.builtin.slurp:
|
|
src: "/etc/docker/daemon.json"
|
|
register: slurp_etc_docker_docker_json
|
|
|
|
- name: "Verify directory /etc/docker"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- stat_etc_docker.stat.exists
|
|
- stat_etc_docker.stat.isdir
|
|
- stat_etc_docker.stat.pw_name == 'root'
|
|
- stat_etc_docker.stat.gr_name == 'root'
|
|
- stat_etc_docker.stat.mode == '0755'
|
|
- stat_etc_docker_docker_json.stat.exists
|
|
- stat_etc_docker_docker_json.stat.isreg
|
|
- stat_etc_docker_docker_json.stat.pw_name == 'root'
|
|
- stat_etc_docker_docker_json.stat.gr_name == 'root'
|
|
- stat_etc_docker_docker_json.stat.mode == '0644'
|
|
- (slurp_etc_docker_docker_json.content|b64decode) == '{}'
|
|
|
|
- name: "Test: interaction docker"
|
|
block:
|
|
- name: "Command docker ps"
|
|
ansible.builtin.command: "docker ps"
|
|
changed_when: false
|
|
register: docker_ps
|
|
|
|
- name: "Verify docker interaction"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- docker_ps.stdout == 'CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES'
|
|
|
|
- name: "Test: file /usr/local/bin/docker-compose"
|
|
block:
|
|
- name: "Stat file /usr/local/bin/docker-compose"
|
|
ansible.builtin.stat:
|
|
path: "/usr/local/bin/docker-compose"
|
|
register: stat_url_local_bin_docker_compose
|
|
|
|
- name: "Verify file /usr/local/bin/docker-compose"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- not stat_url_local_bin_docker_compose.stat.exists
|
|
|
|
- name: "Test: python package docker"
|
|
block:
|
|
- name: "Command pip3 list -o"
|
|
ansible.builtin.command: "pip3 list -o"
|
|
changed_when: false
|
|
register: pip3_list_outdated
|
|
|
|
- name: "Command pip3 list -u"
|
|
ansible.builtin.command: "pip3 list -u"
|
|
changed_when: false
|
|
register: pip3_list_uptodate
|
|
|
|
|
|
- name: "Verify python package docker"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- "'docker' not in pip3_list_outdated.stdout"
|
|
- "'docker' not in pip3_list_uptodate.stdout"
|