community.docker icon indicating copy to clipboard operation
community.docker copied to clipboard

Task docker_swarm_service remove the stack from an existing service

Open pdelaby opened this issue 1 year ago • 1 comments

SUMMARY

Task docker_swarm_service remove the stack from an existing service.

A service "thestack_theservice" is created by docker_stack

- name: Installation de la stack Intoo API 
  docker_stack:
    state: present
    name: "thestack"
    compose:
      - version: "3.8"
        services:
          theservice:
              image: myimage

Then, the service is updated via docker_swarm_service (which shoud do docker service update thestack_theservice --force i guess )

- name: docker service update thestack_theservice --force
  docker_swarm_service:
    name: "thestack_theservice"
    image: myimage
    force_update: true
    state: present

The service is restarted as expected, but is removed from the stack.

In this Portainer screenshot, we can see the first service was created with the stack, and then stopped, and the recreated service has no stack.

Capture d’écran 2022-09-12 152221

ISSUE TYPE
  • Bug Report
COMPONENT NAME

docker_swarm_service

ANSIBLE VERSION
ansible [core 2.13.3]
  config file = None
  configured module search path = ['/home/myself/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myself/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/myself/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/myself/.local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
# /home/myself/.ansible/collections/ansible_collections
Collection       Version
---------------- -------
community.docker 3.1.0

# /usr/lib/python3/dist-packages/ansible_collections
Collection       Version
---------------- -------
community.docker 1.2.2
CONFIGURATION

OS / ENVIRONMENT

Debian in Windows 11, started via wsl --distribution Debian

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
STEPS TO REPRODUCE

Run

- name: docker service update thestack_theservice --force
  docker_swarm_service:
    name: "thestack_theservice"
    image: myimage
    force_update: true
    state: present
EXPECTED RESULTS

docker stack services thestack displays the service

ACTUAL RESULTS

Service is not in the stack anymore

Nothing found in stack: thestack

pdelaby avatar Sep 12 '22 13:09 pdelaby

Then, the service is updated via docker_swarm_service (which shoud do docker service update thestack_theservice --force i guess )

Well, it does not: it calls the Docker API instead. Potentially docker service update thestack_theservice --force does more complicated things than what the module does.

felixfontein avatar Sep 12 '22 18:09 felixfontein