Hello there, hope this is the right place to ask.
Im trying to accomplish the following using docker_compose module, the idea is, I have a compose file which runs
some services and I want to stop some of them but not all, I know beforehands the ones that I do not want to stop, so
am trying to do the following, define vars with the services I do not want to stop, leave them running but the rest.
somehow this is not working for me, the when clause seems not to be being evaluated, services variable and
running_services fact show their content, so is not empty, maybe the services tag in docker_compose expects something
different, if I run the following it just stops all the services.
Any hint really appreciated.
---
- hosts: all
vars:
services:
- service1
- service2
tasks:
- name: Get services
# Retrieve list of services running and register the output.
command: docker-compose -f /path/docker-compose.yml config --services
register: list
# I define running_services fact with the content of list.
- set_fact:
running_services: " list.stdout_lines "
- name: Stop The Services
docker_compose:
project_src: "/path"
services: " running_services"
state: present
stopped: yes
when: running_services not in services
- debug:
var: services
- debug:
var: running_services
services var output.
ok: [1.1.1.1] => {
"services": [
"service1",
"service2"
]
}
running_services output
ok: [1.1.1.1] => {
"running_services": [
"service1",
"service2",
"service3",
"app2",
"app3"
]
}
Thanks
Regards
...