Commit e6020f40 by Joseph Mulloy

Add nginx maintenance page playbook OPS-3164

parent 65154b1a
# Usage:
#
# By default this playbook will disable the maintenance mode
#
# Enable maintenance
# ansible-playbook ./edx_maintenance.yml -i host1.example.com,host2.example.com, -e '{"ENABLE_MAINTENANCE": True}'
#
# Disable maintenance
# ansible-playbook ./edx_maintenance.yml -i host1.example.com,host2.example.com, -e '{"ENABLE_MAINTENANCE": False}'
# ansible-playbook ./edx_maintenance.yml -i host1.example.com,host2.example.com,
#
- name: Deploy edxapp
hosts: all
become: True
gather_facts: True
vars_files:
- 'roles/nginx/defaults/main.yml'
- 'roles/supervisor/defaults/main.yml'
roles:
- role: edx_maintenance
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
##
# Defaults for role edx_maintenance
#
#
# vars are namespace with the module name.
#
ENABLE_MAINTENANCE: False
EDX_MAINTENANCE_SUPERVISOR_APPS:
- 'lms'
- 'cms'
- 'edxapp_worker:'
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
##
# Role includes for role edx_maintenance
#
# Example:
#
# dependencies:
# - {
# role: my_role
# my_role_var0: "foo"
# my_role_var1: "bar"
# }
dependencies:
- common_vars
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role edx_maintenance
#
- name: Find supervisor apps
supervisorctl:
name: "{{ item }}"
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
state: present
become_user: "{{ supervisor_service_user }}"
ignore_errors: yes
register: supervisor_apps
with_items: "{{ EDX_MAINTENANCE_SUPERVISOR_APPS }}"
tags:
- manage
- name: Enable fake heartbeat
copy:
content: ""
dest: "{{ nginx_server_static_dir }}/maintenance_heartbeat.txt"
owner: root
group: "{{ common_web_user }}"
mode: "0640"
when: ENABLE_MAINTENANCE
tags:
- manage
- name: Stop edxapp
supervisorctl:
# Use item.item because item.item strips the : off of edxapp_worker:
name: "{{ item.item }}"
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
state: stopped
become_user: "{{ supervisor_service_user }}"
when: ENABLE_MAINTENANCE and not item is failed
with_items: "{{ supervisor_apps.results }}"
tags:
- manage
- name: Start edxap
supervisorctl:
# Use item.item because item.item strips the : off of edxapp_worker:
name: "{{ item.item }}"
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
state: started
become_user: "{{ supervisor_service_user }}"
when: not ENABLE_MAINTENANCE and not item is failed
with_items: "{{ supervisor_apps.results }}"
tags:
- manage
- name: Disable fake heartbeat
file:
dest: "{{ nginx_server_static_dir }}/maintenance_heartbeat.txt"
state: absent
when: not ENABLE_MAINTENANCE
tags:
- manage
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment