Closed shantanoo-desai closed 1 year ago
---
- hosts: localhost
gather_facts: false
vars_files:
- "{{ playbook_dir }}/../../vars/config.yml"
tasks:
- name: (Komponist-Docker) Obtain Information on Containers
community.docker.docker_container_info:
name: "{{ komponist.project_name }}_{{ item }}"
register: container_results
loop: "{{ komponist.configuration.keys() }}"
- name: (Komponist-Docker) Test if Containers Exist
ansible.builtin.assert:
that: item.exists
fail_msg: "FAIL: {{ item.item }} container DOES NOT Exists."
success_msg: "PASS: {{ item.item }} container Exists."
quiet: true
loop: "{{ container_results.results }}"
loop_control:
label: "{{ item.item }}"
- name: (Komponist-Docker) Test if Container is Running
ansible.builtin.assert:
that: item.container.State.Status == 'running'
fail_msg: "FAIL: {{ item.item }} container NOT RUNNING."
success_msg: "PASS: {{ item.item }} container RUNNING."
quiet: true
loop: "{{ container_results.results }}"
loop_control:
label: "{{ item.item }}"
Description
Add a Container Existence and Running Test via Ansible Playbook by using the
community.docker.docker_container_info
module.Effort
tests/test_containers.yml
playbook to loop over all the services in Komponist and check whether they exist and are running