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" # Run this with "-f 20"
- hosts: 'zuul-scheduler:!disabled' - import_playbook: zuul_stop.yaml
any_errors_fatal: true - import_playbook: zuul_start.yaml
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

View File

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

View File

@ -3,64 +3,21 @@
- hosts: 'zuul-scheduler:!disabled' - hosts: 'zuul-scheduler:!disabled'
any_errors_fatal: true any_errors_fatal: true
tasks: tasks:
- name: Stop Zuul Scheduler - include_role:
service:
name: zuul-scheduler name: zuul-scheduler
state: stopped tasks_from: stop
become: true - include_role:
become_user: root
- name: Stop Zuul Web
service:
name: zuul-web name: zuul-web
state: stopped tasks_from: stop
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' - hosts: 'zuul-merger:!disabled'
tasks: tasks:
- name: Stop Zuul Merger - include_role:
service:
name: zuul-merger name: zuul-merger
state: stopped tasks_from: stop
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
- hosts: 'zuul-executor:!disabled' - hosts: 'zuul-executor:!disabled'
tasks: tasks:
- name: Stop Zuul Executor - include_role:
service:
name: zuul-executor name: zuul-executor
state: stopped tasks_from: stop
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