install_docker/molecule/default_vagrant/verify.yml
Bertrand Lanson 24c4a8e19d
All checks were successful
test / Linting (push) Successful in 10s
test / Molecule tests (default, debian12) (push) Successful in 1m31s
test / Molecule tests (default, debian11) (push) Successful in 1m40s
test / Molecule tests (default, ubuntu2004) (push) Successful in 1m49s
test / Molecule tests (default, ubuntu2204) (push) Successful in 1m39s
test / Molecule tests (with_custom_config, debian11) (push) Successful in 1m53s
test / Molecule tests (with_custom_config, ubuntu2004) (push) Successful in 2m10s
test / Molecule tests (with_custom_config, ubuntu2204) (push) Successful in 1m56s
test / Molecule tests (with_custom_config, debian12) (push) Successful in 1m44s
feat(tests): remove /etc/hosts testing, fix #1
2023-12-08 23:03:43 +01:00

97 lines
3.6 KiB
YAML

---
- name: Verify
hosts: all
gather_facts: true
become: true
tasks:
- 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"
ansible.builtin.command: "pip3 list -o"
changed_when: false
register: pip3_list
- name: "Verify python package docker"
ansible.builtin.assert:
that:
- "'docker' not in pip3_list"