- name: deploy docker stack hosts: localhost tasks: - name: Tear down existing services community.docker.docker_compose: project_src: ../ state: absent - name: Create and start services community.docker.docker_compose: project_src: ../ register: output - name: Show results ansible.builtin.debug: var: output - name: Run `docker-compose up` again community.docker.docker_compose: project_src: ../ build: false register: output # - name: Show results # ansible.builtin.debug: # var: output # - ansible.builtin.assert: # that: not output.changed # - name: Stop all services # community.docker.docker_compose: # project_src: ../ # build: false # stopped: true # register: output - name: Show results ansible.builtin.debug: var: output - name: Verify that app and db services are running ansible.builtin.assert: that: - "not output.services.app.oonyeje-portfolio_app_1.state.running" # - name: Restart services # community.docker.docker_compose: # project_src: ../ # build: false # restarted: true # register: output - name: Show results ansible.builtin.debug: var: output # - name: Verify that app and db services are running # ansible.builtin.assert: # that: # - "not output.services.app.oonyeje-portfolio_app_1.state.running"