On 5/9/20 5:32 AM, Kernel Panic wrote:
> 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.

I think that defeats the purpose of docker-compose. You could stop the services 
with the docker_container module.

Regards
        Racke

> 
> ---
> - 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
> 
> 
> ...
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/36ff7267-1fb4-4a23-ba26-2abf2423bdf1%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/36ff7267-1fb4-4a23-ba26-2abf2423bdf1%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b7ca1330-aa5c-e7e6-7e4e-24859f88e85c%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to