Rework zuul start/stop/restart playbooks for docker

If we need to start and stop, it's best to use playbooks.

We already have tasks files with start commands in each role,
so put the stop commands into similar task files.

Make the restart playbook import_playbook the stop and start
playbooks to reduce divergence.

Use the graceful shutdown pattern from the gerrit docker-compose
to stop the zuul scheduler.

Change-Id: Ia20124553821f4b41186bce6ba2bff6ca2333a99
This commit is contained in:
Monty Taylor 2020-04-24 17:25:41 -05:00
parent 5d1f556c2e
commit 2a7c755a08
9 changed files with 66 additions and 184 deletions

View File

@ -0,0 +1,12 @@
- name: Stop Zuul Executor
service:
name: zuul-executor
state: stopped
become: true
become_user: root
- name: Wait for (3h10m) to stop Zuul Executor
wait_for:
path: /var/run/zuul/executor.pid
state: absent
timeout: 11400

View File

@ -0,0 +1,6 @@
- name: Stop Zuul Merger
shell:
cmd: docker-compose down
chdir: /etc/zuul-merger
become: true
become_user: root

View File

@ -0,0 +1,6 @@
- name: Stop Zuul Scheduler
shell:
cmd: docker-compose down
chdir: /etc/zuul-scheduler
become: true
become_user: root

View File

@ -0,0 +1,6 @@
- name: Stop Zuul Web and Finger Gateway
shell:
cmd: docker-compose down
chdir: /etc/zuul-web
become: true
become_user: root

View File

@ -0,0 +1,9 @@
- hosts: zuul-merger
tasks:
- shell:
cmd: docker-compose up -d
chdir: /etc/zuul-merger
- hosts: zuul-executor
tasks:
- shell: systemctl start zuul-executor

View File

@ -0,0 +1,9 @@
- hosts: zuul-merger
tasks:
- shell:
cmd: docker-compose down
chdir: /etc/zuul-merger
- hosts: zuul-executor
tasks:
- shell: systemctl stop zuul-executor

View File

@ -1,109 +1,4 @@
# Run this with "-f 20"
- hosts: 'zuul-scheduler:!disabled'
any_errors_fatal: true
tasks:
- name: Stop Zuul Scheduler
service:
name: zuul-scheduler
state: stopped
become: true
become_user: root
- name: Stop Zuul Web
service:
name: zuul-web
state: stopped
become: true
become_user: root
- name: Stop Zuul Finger Gateway
service:
name: zuul-fingergw
state: stopped
become: true
become_user: root
- name: Wait for (3h10m) to stop Zuul Scheduler
wait_for:
path: /var/run/zuul/scheduler.pid
state: absent
timeout: 11400
- name: Wait for (3h10m) to stop Zuul Web
wait_for:
path: /var/run/zuul/web.pid
state: absent
timeout: 11400
- name: Wait for (3h10m) to stop Zuul Finger Gateway
wait_for:
path: /var/run/zuul/fingergw.pid
state: absent
timeout: 11400
- hosts: 'zuul-merger:!disabled'
tasks:
- name: Stop Zuul Mergers
service:
name: zuul-merger
state: stopped
become: true
become_user: root
- hosts: 'zuul-executor:!disabled'
tasks:
- name: Stop Zuul Executors
service:
name: zuul-executor
state: stopped
become: true
become_user: root
- hosts: 'zuul-scheduler:!disabled'
tasks:
- name: Start Zuul Scheduler
service:
name: zuul-scheduler
state: started
become: true
become_user: root
- name: Start Zuul Web
service:
name: zuul-web
state: started
become: true
become_user: root
- name: Start Zuul Finger Gateway
service:
name: zuul-fingergw
state: started
become: true
become_user: root
- hosts: 'zuul-merger:!disabled'
tasks:
- name: Wait for (3h10m) to stop Zuul Mergers
wait_for:
path: /var/run/zuul/merger.pid
state: absent
timeout: 11400
- name: Start Zuul Mergers
service:
name: zuul-merger
state: started
become: true
become_user: root
- hosts: 'zuul-executor:!disabled'
tasks:
- name: Wait for (3h10m) to stop Zuul Executors
wait_for:
path: /var/run/zuul/executor.pid
state: absent
timeout: 11400
- name: Update the ansible installations
command: zuul-manage-ansible -u
environment:
ANSIBLE_EXTRA_PACKAGES: gear
- name: Start Zuul Executors
service:
name: zuul-executor
state: started
become: true
become_user: root
- import_playbook: zuul_stop.yaml
- import_playbook: zuul_start.yaml

View File

@ -2,39 +2,21 @@
- hosts: 'zuul-scheduler:!disabled'
tasks:
- name: Start Zuul Scheduler
service:
- include_role:
name: zuul-scheduler
state: started
become: true
become_user: root
- name: Stop Zuul Web
service:
tasks_from: start
- include_role:
name: zuul-web
state: started
become: true
become_user: root
- name: Stop Zuul Finger Gateway
service:
name: zuul-fingergw
state: started
become: true
become_user: root
tasks_from: start
- hosts: 'zuul-merger:!disabled'
tasks:
- name: Start Zuul Mergers
service:
- include_role:
name: zuul-merger
state: started
become: true
become_user: root
tasks_from: start
- hosts: 'zuul-executor:!disabled'
tasks:
- name: Start Zuul Executors
service:
- include_role:
name: zuul-executor
state: started
become: true
become_user: root
tasks_from: start

View File

@ -3,64 +3,21 @@
- hosts: 'zuul-scheduler:!disabled'
any_errors_fatal: true
tasks:
- name: Stop Zuul Scheduler
service:
- include_role:
name: zuul-scheduler
state: stopped
become: true
become_user: root
- name: Stop Zuul Web
service:
tasks_from: stop
- include_role:
name: zuul-web
state: stopped
become: true
become_user: root
- name: Stop Zuul Finger Gateway
service:
name: zuul-fingergw
state: stopped
become: true
become_user: root
- name: Wait for (3h10m) to stop Zuul Scheduler
wait_for:
path: /var/run/zuul/scheduler.pid
state: absent
timeout: 11400
- name: Wait for (3h10m) to stop Zuul Web
wait_for:
path: /var/run/zuul/web.pid
state: absent
timeout: 11400
- name: Wait for (3h10m) to stop Zuul Finger Gateway
wait_for:
path: /var/run/zuul/fingergw.pid
state: absent
timeout: 11400
tasks_from: stop
- hosts: 'zuul-merger:!disabled'
tasks:
- name: Stop Zuul Merger
service:
- include_role:
name: zuul-merger
state: stopped
become: true
become_user: root
- name: Wait for (3h10m) to stop Zuul Merger
wait_for:
path: /var/run/zuul/merger.pid
state: absent
timeout: 11400
tasks_from: stop
- hosts: 'zuul-executor:!disabled'
tasks:
- name: Stop Zuul Executor
service:
- include_role:
name: zuul-executor
state: stopped
become: true
become_user: root
- name: Wait for (3h10m) to stop Zuul Executor
wait_for:
path: /var/run/zuul/executor.pid
state: absent
timeout: 11400
tasks_from: stop