Files
2024-07-28 01:20:10 +03:00

45 lines
1.9 KiB
YAML

---
# This is an example playbook to execute Ansible tests.
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Ensure https://localhost responds appropriately
ansible.builtin.uri:
url: https://localhost
validate_certs: false
return_content: true
register: get_localhost
- name: "Assert caddy responded on https://localhost"
ansible.builtin.assert:
that: "(get_localhost.server | split(', '))[0] == 'Caddy'"
- name: "Assert apache responded on https://localhost"
ansible.builtin.assert:
that: "(get_localhost.server | split(', '))[1].startswith('Apache')"
- name: Assert there was a redirect
ansible.builtin.assert:
that: "get_localhost.redirected == true"
- name: Get docker host info
community.docker.docker_host_info:
volumes: true
register: docker_host_out
- name: Assert all containers are running
ansible.builtin.assert:
that: docker_host_out.host_info.Containers == docker_host_out.host_info.ContainersRunning
msg: There should have been {{ docker_host_out.host_info.Containers }} containers running but there were {{ docker_host_out.host_info.ContainersRunning }}
- name: Assert correct number of containers were created
ansible.builtin.assert:
that: docker_host_out.host_info.Containers == 4
msg: There should have been 4 containers created but there were {{ docker_host_out.host_info.Containers }}
- name: Assert correct number of images were pulled
ansible.builtin.assert:
that: docker_host_out.host_info.Images == 6
msg: There should have been 4 images present but there were {{ docker_host_out.host_info.Images }}
- name: Assert no volumes were created
ansible.builtin.assert:
that: docker_host_out.volumes | length == 0
msg: There should have been no volumes present but there were {{ docker_host_out.volumes | length }}