system-config/playbooks/roles/zuul-executor/tasks/graceful.yaml
Clark Boylan 46ba1ff961 Use docker-compose exec -T with ansible tasks
Docker-compose exec allocates a tty by default unlike docker exec. New
Ansible doesn't provision a tty which causes docker-compose exec to fail
under Ansible now. Address this by passing -T to docker-compose exec
commands which stops allocating a tty. We didn't need one to gracefully
stop zuul services.

Change-Id: Ib52f184f771ae4530f6b6531257dda5d8443043c
2022-12-12 08:03:19 -08:00

36 lines
1.2 KiB
YAML

- name: Check if Zuul Executor containers are running
# It is possible they are stopped due to some external circumstance.
# NOTE: docker-compose ps -q reports exited containers unlike docker ps -q
command:
cmd: docker-compose ps -q
chdir: /etc/zuul-executor
become: true
become_user: root
register: executor_container_list
- name: Gracefully stop Zuul Executor
shell:
cmd: docker-compose exec -T executor zuul-executor graceful
chdir: /etc/zuul-executor
become: true
become_user: root
# Only run the docker exec command if a container is running
when: executor_container_list.stdout_lines | length > 0
register: ze_graceful
failed_when:
- ze_graceful.rc != 0
# If the exec fails because the container is not running we continue.
- "'No container found' not in ze_graceful.stderr"
- name: Wait for Zuul Executor to stop
shell:
cmd: docker-compose ps -q | xargs docker wait
chdir: /etc/zuul-executor
become: true
become_user: root
when: executor_container_list.stdout_lines | length > 0
- name: Remove Zuul Executor containers
shell:
cmd: docker-compose down
chdir: /etc/zuul-executor
become: true
become_user: root