James E. Blair 1c069add54 Run zuul-launcher
This doesn't do anything substantial yet, but we'd like to start running
the server soon in order to test it out.

Change-Id: I9eb2bccd6e5e9a064cbaff10676aeb1af6653f98
2024-09-18 16:37:40 -07:00

43 lines
1.6 KiB
YAML

- name: Check if Zuul launcher 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-launcher
become: true
become_user: root
register: launcher_container_list
- name: Gracefully stop Zuul Launcher
shell:
cmd: docker-compose exec -T launcher zuul-launcher stop
chdir: /etc/zuul-launcher
become: true
become_user: root
# Only run the docker exec command if a container is running
when: launcher_container_list.stdout_lines | length > 0
register: zl_graceful
failed_when:
- zl_graceful.rc != 0
# There is a fun race with docker exec and shutting down the
# container running the exec. If the container is stopped while
# the exec is running then the command in the exec effectively gets
# kill -9'd and the docker exec command rc is 137. Since this
# should only happen when the container is stopped we proceed with
# the overall graceful shutdown.
- zl_graceful.rc != 137
# If the exec fails because the container is not running we continue.
- "'No container found' not in zl_graceful.stderr"
- name: Wait for Zuul Launcher to stop
shell:
cmd: docker-compose ps -q | xargs docker wait
chdir: /etc/zuul-launcher
become: true
become_user: root
when: launcher_container_list.stdout_lines | length > 0
- name: Down Zuul Launcher containers
shell:
cmd: docker-compose down
chdir: /etc/zuul-launcher
become: true
become_user: root