Commit cb65e84e by John Jarvis

supervisor service and file management refactor

parent c5d07f35
...@@ -10,13 +10,15 @@ ...@@ -10,13 +10,15 @@
# #
# #
# Handlers for role analytics-server # Handlers for role analytics-server
# #
# Overview: # Overview:
# #
# #
- name: analytics-server | stop the analytics service - name: analytics-server | stop the analytics service
service: name=analytics state=stopped service: name=analytics state=stopped
tags: deploy
- name: analytics-server | start the analytics service - name: analytics-server | start the analytics service
service: name=analytics state=started service: name=analytics state=started
tags: deploy
...@@ -10,13 +10,15 @@ ...@@ -10,13 +10,15 @@
# #
# #
# Handlers for role analytics # Handlers for role analytics
# #
# Overview: # Overview:
# #
# #
- name: analytics | stop the analytics service - name: analytics | stop the analytics service
service: name=analytics state=stopped service: name=analytics state=stopped
tags: deploy
- name: analytics | start the analytics service - name: analytics | start the analytics service
service: name=analytics state=started service: name=analytics state=started
tags: deploy
--- ---
- name: apache | restart apache - name: apache | restart apache
service: name=apache2 state=restarted service: name=apache2 state=restarted
tags: deploy
...@@ -20,4 +20,5 @@ ...@@ -20,4 +20,5 @@
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
tags: deploy
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
- name: certs | writing supervisor script for certificates - name: certs | writing supervisor script for certificates
template: > template: >
src=certs.conf.j2 dest={{ supervisor_cfg_dir }}/certs.conf src=certs.conf.j2 dest={{ supervisor_cfg_dir }}/certs.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644 owner={{ supervisor_user }} mode=0644
notify: certs | restart certs notify: certs | restart certs
tags: deploy tags: deploy
...@@ -55,3 +55,22 @@ ...@@ -55,3 +55,22 @@
sudo_user: "{{ certs_user }}" sudo_user: "{{ certs_user }}"
notify: certs | restart certs notify: certs | restart certs
tags: deploy tags: deploy
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
- name: certs | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
sudo_user: "{{ supervisor_service_user }}"
changed_when: supervisor_update.stdout != ""
- name: certs | ensure certs has started
supervisorctl: >
name=certs
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
sudo_user: "{{ supervisor_service_user }}"
...@@ -88,16 +88,3 @@ ...@@ -88,16 +88,3 @@
with_items: with_items:
- python - python
- pip - pip
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: certs | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
...@@ -2,3 +2,4 @@ ...@@ -2,3 +2,4 @@
- name: common | restart rsyslogd - name: common | restart rsyslogd
service: name=rsyslog state=restarted service: name=rsyslog state=restarted
sudo: True sudo: True
tags: deploy
--- ---
- name: datadog | restart the datadog service - name: datadog | restart the datadog service
service: name=datadog-agent state=restarted service: name=datadog-agent state=restarted
\ No newline at end of file tags: deploy
...@@ -18,3 +18,4 @@ ...@@ -18,3 +18,4 @@
config={{ devpi_supervisor_cfg }} config={{ devpi_supervisor_cfg }}
name=devpi-server name=devpi-server
sudo_user: "{{ devpi_supervisor_user }}" sudo_user: "{{ devpi_supervisor_user }}"
tags: deploy
...@@ -5,10 +5,12 @@ ...@@ -5,10 +5,12 @@
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
tags: deploy
- name: discern | restart discern_celery - name: discern | restart discern_celery
supervisorctl: > supervisorctl: >
name=discern_celery name=discern_celery
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
tags: deploy
state=restarted state=restarted
--- ---
- name: discern | create supervisor scripts - discern, discern_celery
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} mode=0644
sudo_user: "{{ supervisor_user }}"
with_items: ['discern', 'discern_celery']
#Upload config files for django (auth and env) #Upload config files for django (auth and env)
- name: discern | create discern application config env.json file - name: discern | create discern application config env.json file
template: src=env.json.j2 dest={{ discern_app_dir }}/env.json template: src=env.json.j2 dest={{ discern_app_dir }}/env.json
...@@ -109,3 +116,61 @@ ...@@ -109,3 +116,61 @@
- discern | restart discern - discern | restart discern
tags: tags:
- deploy - deploy
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: discern | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
sudo_user: "{{ supervisor_service_user }}"
changed_when: supervisor_update.stdout != ""
- name: discern | ensure discern has started
supervisorctl: >
name=discern
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
sudo_user: "{{ supervisor_service_user }}"
- name: discern_celery | ensure discern_celery has started
supervisorctl: >
name=discern_celery
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
sudo_user: "{{ supervisor_service_user }}"
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
- name: discern | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
sudo_user: "{{ supervisor_service_user }}"
changed_when: supervisor_update.stdout != ""
- name: discern | ensure discern, discern_celery has started
supervisorctl: >
name={{ item }}
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
with_items:
- discern
- discern_celery
- name: discern | create a symlink for venv python
file: >
src="{{ discern_venv_bin }}/python"
dest={{ COMMON_BIN_DIR }}/python.discern
state=link
...@@ -60,29 +60,4 @@ ...@@ -60,29 +60,4 @@
- discern | restart discern_celery - discern | restart discern_celery
- discern | restart discern - discern | restart discern
- name: discern | create supervisor scripts - discern, discern_celery
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
with_items: ['discern', 'discern_celery']
- include: deploy.yml - include: deploy.yml
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: discern | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
- name: discern | create a symlink for venv python
file: >
src="{{ discern_venv_bin }}/python"
dest={{ COMMON_BIN_DIR }}/python.discern
state=link
--- ---
- name: "edxapp | restart edxapp:lms" - name: "edxapp | restart edxapp"
supervisorctl: > supervisorctl: >
state=restarted state=restarted
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
name="edxapp:lms" name="edxapp:{{ item }}"
sudo_user: "{{ supervisor_user }}" sudo_user: "{{ supervisor_service_user }}"
with_items: service_variants_enabled
tags: deploy
- name: "edxapp | restart edxapp:cms" - name: "edxapp | restart edxapp_workers"
supervisorctl: > supervisorctl: >
state=restarted name="edxapp_worker:{{ item.service_variant }}_{{ item.queue }}_{{ item.concurrency }}"
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
name="edxapp:cms" state=restarted
sudo_user: "{{ supervisor_user }}" when: celery_worker is defined
with_items: edxapp_workers
sudo_user: "{{ common_web_user }}"
tags: deploy
# Stop all services.
#
#
# TODO: the supervisor ansible module does not support
# stopping and starting services by group.
# Do A Checkout # Do A Checkout
- name: edxapp | checkout edx-platform repo into {{edxapp_code_dir}} - name: edxapp | checkout edx-platform repo into {{edxapp_code_dir}}
git: dest={{edxapp_code_dir}} repo={{edx_platform_repo}} version={{edx_platform_commit}} git: dest={{edxapp_code_dir}} repo={{edx_platform_repo}} version={{edx_platform_commit}}
register: chkout register: chkout
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
- name: edxapp | git clean after checking out edx-platform - name: edxapp | git clean after checking out edx-platform
shell: cd {{edxapp_code_dir}} && git clean -xdf shell: cd {{edxapp_code_dir}} && git clean -xdf
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
- name: edxapp | checkout theme - name: edxapp | checkout theme
git: dest={{ edxapp_app_dir }}/themes/{{edxapp_theme_name}} repo={{edxapp_theme_source_repo}} version={{edxapp_theme_version}} git: dest={{ edxapp_app_dir }}/themes/{{edxapp_theme_name}} repo={{edxapp_theme_source_repo}} version={{edxapp_theme_version}}
when: edxapp_theme_name != '' when: edxapp_theme_name != ''
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: tags:
- deploy - deploy
...@@ -48,6 +50,9 @@ ...@@ -48,6 +50,9 @@
command: | command: |
/bin/sed -i -e 's/github\.com/{{ COMMON_GIT_MIRROR }}/g' {{ " ".join(edxapp_all_req_files) }} /bin/sed -i -e 's/github\.com/{{ COMMON_GIT_MIRROR }}/g' {{ " ".join(edxapp_all_req_files) }}
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
# Ruby plays that need to be run after platform updates. # Ruby plays that need to be run after platform updates.
...@@ -58,6 +63,9 @@ ...@@ -58,6 +63,9 @@
executable=/bin/bash executable=/bin/bash
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
- name: edxapp | bundle install - name: edxapp | bundle install
...@@ -67,6 +75,9 @@ ...@@ -67,6 +75,9 @@
executable=/bin/bash executable=/bin/bash
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
# Node play that need to be run after platform updates. # Node play that need to be run after platform updates.
...@@ -74,6 +85,9 @@ ...@@ -74,6 +85,9 @@
shell: npm install chdir={{ edxapp_code_dir }} shell: npm install chdir={{ edxapp_code_dir }}
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
...@@ -86,6 +100,9 @@ ...@@ -86,6 +100,9 @@
extra_args="-i {{ edxapp_pypi_local_mirror }}" extra_args="-i {{ edxapp_pypi_local_mirror }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
when: not inst.stat.exists or new.stat.md5 != inst.stat.md5 when: not inst.stat.exists or new.stat.md5 != inst.stat.md5
tags: deploy tags: deploy
...@@ -99,6 +116,9 @@ ...@@ -99,6 +116,9 @@
chdir={{ edxapp_code_dir }} chdir={{ edxapp_code_dir }}
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
when: not inst.stat.exists or new.stat.md5 != inst.stat.md5 when: not inst.stat.exists or new.stat.md5 != inst.stat.md5
tags: deploy tags: deploy
...@@ -111,6 +131,9 @@ ...@@ -111,6 +131,9 @@
extra_args="-i {{ edxapp_pypi_local_mirror }}" extra_args="-i {{ edxapp_pypi_local_mirror }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
when: not inst.stat.exists or new.stat.md5 != inst.stat.md5 when: not inst.stat.exists or new.stat.md5 != inst.stat.md5
tags: deploy tags: deploy
...@@ -125,6 +148,9 @@ ...@@ -125,6 +148,9 @@
- "{{ github_requirements_file }}" - "{{ github_requirements_file }}"
- "{{ local_requirements_file }}" - "{{ local_requirements_file }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
...@@ -141,11 +167,17 @@ ...@@ -141,11 +167,17 @@
when: install_sandbox_reqs_into_regular_venv when: install_sandbox_reqs_into_regular_venv
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
when: not inst.stat.exists or new.stat.md5 != inst.stat.md5 when: not inst.stat.exists or new.stat.md5 != inst.stat.md5
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
- name: edxapp | compiling all py files in the edx-platform repo - name: edxapp | compiling all py files in the edx-platform repo
shell: "{{ edxapp_venv_bin }}/python -m compileall {{ edxapp_code_dir }}" shell: "{{ edxapp_venv_bin }}/python -m compileall {{ edxapp_code_dir }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
# alternative would be to give {{ common_web_user }} read access # alternative would be to give {{ common_web_user }} read access
...@@ -154,11 +186,15 @@ ...@@ -154,11 +186,15 @@
- name: edxapp | give other read permissions to the virtualenv - name: edxapp | give other read permissions to the virtualenv
command: chmod -R o+r "{{ edxapp_venv_dir }}" command: chmod -R o+r "{{ edxapp_venv_dir }}"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: deploy tags: deploy
- name: edxapp | create checksum for installed requirements - name: edxapp | create checksum for installed requirements
shell: cp /var/tmp/edxapp.req.new /var/tmp/edxapp.req.installed shell: cp /var/tmp/edxapp.req.new /var/tmp/edxapp.req.installed
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify: "edxapp | restart edxapp"
tags: deploy tags: deploy
...@@ -170,6 +206,9 @@ ...@@ -170,6 +206,9 @@
shell: sed -i -e 's/claimed_id = models.TextField(max_length=2047, unique=True/claimed_id = models.TextField(max_length=2047/' {{ edxapp_venv_dir }}/lib/python2.7/site-packages/django_openid_auth/models.py shell: sed -i -e 's/claimed_id = models.TextField(max_length=2047, unique=True/claimed_id = models.TextField(max_length=2047/' {{ edxapp_venv_dir }}/lib/python2.7/site-packages/django_openid_auth/models.py
when: openid_workaround is defined when: openid_workaround is defined
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: tags:
- deploy - deploy
...@@ -178,19 +217,27 @@ ...@@ -178,19 +217,27 @@
# gather_assets and db migrations # gather_assets and db migrations
- include: service_variant_config.yml - include: service_variant_config.yml
- name: edxapp | restart the edxapp services (supervisor) # call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
- name: edxapp | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
sudo_user: "{{ supervisor_service_user }}"
changed_when: supervisor_update.stdout != ""
- name: edxapp | ensure edxapp has started
supervisorctl: > supervisorctl: >
name="edxapp:{{ item }}" state=restarted
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted name="edxapp:{{ item }}"
when: celery_worker is not defined sudo_user: "{{ supervisor_service_user }}"
with_items: service_variants_enabled with_items: service_variants_enabled
sudo_user: "{{ common_web_user }}"
tags:
- deploy
- name: edxapp | restart the celery worker services (supervisor) - name: edxapp | ensure edxapp_workers has started
supervisorctl: > supervisorctl: >
name="edxapp_worker:{{ item.service_variant }}_{{ item.queue }}_{{ item.concurrency }}" name="edxapp_worker:{{ item.service_variant }}_{{ item.queue }}_{{ item.concurrency }}"
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
...@@ -198,6 +245,5 @@ ...@@ -198,6 +245,5 @@
state=restarted state=restarted
when: celery_worker is defined when: celery_worker is defined
with_items: edxapp_workers with_items: edxapp_workers
sudo_user: "{{ common_web_user }}" sudo_user: "{{ supervisor_service_user }}"
tags: tags:
- deploy
...@@ -6,16 +6,25 @@ ...@@ -6,16 +6,25 @@
- name: edxapp | Install logrotate configuration for tracking file - name: edxapp | Install logrotate configuration for tracking file
template: dest=/etc/logrotate.d/tracking.log src=edx_logrotate_tracking_log.j2 owner=root group=root mode=644 template: dest=/etc/logrotate.d/tracking.log src=edx_logrotate_tracking_log.j2 owner=root group=root mode=644
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
- name: edxapp | create application user - name: edxapp | create application user
user: > user: >
name="{{ edxapp_user }}" home="{{ edxapp_app_dir }}" name="{{ edxapp_user }}" home="{{ edxapp_app_dir }}"
createhome=no shell=/bin/false createhome=no shell=/bin/false
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
- name: edxapp | create edxapp user dirs - name: edxapp | create edxapp user dirs
file: > file: >
path="{{ item }}" state=directory path="{{ item }}" state=directory
owner="{{ edxapp_user }}" group="{{ common_web_group }}" owner="{{ edxapp_user }}" group="{{ common_web_group }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
with_items: with_items:
- "{{ edxapp_app_dir }}" - "{{ edxapp_app_dir }}"
- "{{ edxapp_data_dir }}" - "{{ edxapp_data_dir }}"
...@@ -27,20 +36,32 @@ ...@@ -27,20 +36,32 @@
file: > file: >
path="{{ edxapp_log_dir }}" state=directory path="{{ edxapp_log_dir }}" state=directory
owner="{{ common_log_user }}" group="{{ common_log_user }}" owner="{{ common_log_user }}" group="{{ common_log_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
- name: edxapp | create web-writable edxapp data dirs - name: edxapp | create web-writable edxapp data dirs
file: > file: >
path="{{ item }}" state=directory path="{{ item }}" state=directory
owner="{{ common_web_user }}" group="{{ edxapp_user }}" owner="{{ common_web_user }}" group="{{ edxapp_user }}"
mode="0775" mode="0775"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
with_items: with_items:
- "{{ edxapp_course_data_dir }}" - "{{ edxapp_course_data_dir }}"
- "{{ edxapp_upload_dir }}" - "{{ edxapp_upload_dir }}"
- name: edxapp | install system packages on which LMS and CMS rely - name: edxapp | install system packages on which LMS and CMS rely
apt: pkg={{','.join(edxapp_debian_pkgs)}} state=present apt: pkg={{','.join(edxapp_debian_pkgs)}} state=present
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
- name: edxapp | create log directories for service variants - name: edxapp | create log directories for service variants
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
file: > file: >
path={{ edxapp_log_dir }}/{{ item }} state=directory path={{ edxapp_log_dir }}/{{ item }} state=directory
owner={{ common_log_user }} group={{ common_log_user }} owner={{ common_log_user }} group={{ common_log_user }}
...@@ -48,6 +69,9 @@ ...@@ -48,6 +69,9 @@
with_items: service_variants_enabled with_items: service_variants_enabled
- name: edxapp | setup the edxapp env - name: edxapp | setup the edxapp env
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
template: > template: >
src=edxapp_env.j2 dest={{ edxapp_app_dir }}/edxapp_env src=edxapp_env.j2 dest={{ edxapp_app_dir }}/edxapp_env
owner={{ edxapp_user }} group={{ common_web_user }} owner={{ edxapp_user }} group={{ common_web_user }}
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
dest={{ edxapp_app_dir }}/{{ item }}.env.json dest={{ edxapp_app_dir }}/{{ item }}.env.json
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
with_items: service_variants_enabled with_items: service_variants_enabled
notify: "edxapp | restart edxapp:{{ item }}" notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: tags:
- deploy - deploy
...@@ -13,7 +15,9 @@ ...@@ -13,7 +15,9 @@
src={{ item }}.auth.json.j2 src={{ item }}.auth.json.j2
dest={{ edxapp_app_dir }}/{{ item }}.auth.json dest={{ edxapp_app_dir }}/{{ item }}.auth.json
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify: "edxapp | restart edxapp:{{ item }}" notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
with_items: service_variants_enabled with_items: service_variants_enabled
tags: tags:
- deploy - deploy
...@@ -50,19 +54,6 @@ ...@@ -50,19 +54,6 @@
tags: tags:
- deploy - deploy
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: edxapp | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
# Gather assets using rake if possible # Gather assets using rake if possible
...@@ -74,6 +65,9 @@ ...@@ -74,6 +65,9 @@
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
when: celery_worker is not defined when: celery_worker is not defined
with_items: service_variants_enabled with_items: service_variants_enabled
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
environment: "{{ edxapp_environment }}" environment: "{{ edxapp_environment }}"
tags: tags:
- deploy - deploy
...@@ -83,14 +77,18 @@ ...@@ -83,14 +77,18 @@
shell: SERVICE_VARIANT=lms {{ edxapp_venv_bin}}/django-admin.py syncdb --migrate --noinput --settings=lms.envs.aws --pythonpath={{ edxapp_code_dir }} shell: SERVICE_VARIANT=lms {{ edxapp_venv_bin}}/django-admin.py syncdb --migrate --noinput --settings=lms.envs.aws --pythonpath={{ edxapp_code_dir }}
when: migrate_db is defined and migrate_db|lower == "yes" when: migrate_db is defined and migrate_db|lower == "yes"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
tags: tags:
- deploy - deploy
- name: edxapp | db migrate - name: edxapp | db migrate
shell: SERVICE_VARIANT=lms {{ edxapp_venv_bin }}/django-admin.py migrate --noinput --settings=lms.envs.aws --pythonpath={{ edxapp_code_dir }} shell: SERVICE_VARIANT=lms {{ edxapp_venv_bin }}/django-admin.py migrate --noinput --settings=lms.envs.aws --pythonpath={{ edxapp_code_dir }}
when: migrate_only is defined and migrate_only|lower == "yes" when: migrate_only is defined and migrate_only|lower == "yes"
notify:
- "edxapp | restart edxapp"
- "edxapp | restart edxapp_workers"
sudo_user: "{{ edxapp_user }}" sudo_user: "{{ edxapp_user }}"
tags: tags:
- deploy - deploy
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
tags: deploy
--- ---
- name: forum | create the supervisor config
template: >
src=forum.conf.j2 dest={{ supervisor_cfg_dir }}/forum.conf
owner={{ supervisor_user }}
mode=0644
sudo_user: "{{ supervisor_user }}"
register: forum_supervisor
tags: deploy
- name: forum | create the supervisor wrapper - name: forum | create the supervisor wrapper
template: > template: >
src={{ forum_supervisor_wrapper|basename }}.j2 src={{ forum_supervisor_wrapper|basename }}.j2
...@@ -7,15 +16,13 @@ ...@@ -7,15 +16,13 @@
mode=0755 mode=0755
sudo_user: "{{ forum_user }}" sudo_user: "{{ forum_user }}"
notify: forum | restart the forum service notify: forum | restart the forum service
tags: tags: deploy
- deploy
- name: forum | git checkout forum repo into {{ forum_code_dir }} - name: forum | git checkout forum repo into {{ forum_code_dir }}
git: dest={{ forum_code_dir }} repo={{ forum_source_repo }} version={{ forum_version }} git: dest={{ forum_code_dir }} repo={{ forum_source_repo }} version={{ forum_version }}
sudo_user: "{{ forum_user }}" sudo_user: "{{ forum_user }}"
notify: forum | restart the forum service notify: forum | restart the forum service
tags: tags: deploy
- deploy
# TODO: This is done as the common_web_user # TODO: This is done as the common_web_user
# since the process owner needs write access # since the process owner needs write access
...@@ -25,15 +32,23 @@ ...@@ -25,15 +32,23 @@
sudo_user: "{{ common_web_user }}" sudo_user: "{{ common_web_user }}"
environment: "{{ forum_environment }}" environment: "{{ forum_environment }}"
notify: forum | restart the forum service notify: forum | restart the forum service
tags: tags: deploy
- deploy
- name: forum | create the supervisor config # call supervisorctl update. this reloads
template: > # the supervisorctl config and restarts
src=forum.conf.j2 dest={{ supervisor_cfg_dir }}/forum.conf # the services if any of the configurations
owner={{ common_web_user }} group={{ supervisor_user }} # have changed.
mode=0644 #
register: forum_supervisor - name: forum | update supervisor configuration
notify: forum | restart the forum service shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
tags: register: supervisor_update
- deploy changed_when: supervisor_update.stdout != ""
tags: deploy
- name: forum | ensure forum is started
supervisorctl: >
name=forum
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
tags: deploy
...@@ -42,27 +42,6 @@ ...@@ -42,27 +42,6 @@
notify: notify:
- forum | restart the forum service - forum | restart the forum service
- name: forum | create the supervisor config
template: >
src=forum.conf.j2 dest={{ supervisor_cfg_dir }}/forum.conf
owner={{ common_web_user }} group={{ supervisor_user }}
mode=0644
register: forum_supervisor
- include: deploy.yml - include: deploy.yml
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: forum | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
- include: test.yml - include: test.yml
--- ---
- name: restart mongo - name: restart mongo
service: name=mongodb state=restarted service: name=mongodb state=restarted
tags: deploy
--- ---
- name: nginx | restart nginx - name: nginx | restart nginx
service: name=nginx state=restarted service: name=nginx state=restarted
tags: deploy
- name: nginx | reload nginx - name: nginx | reload nginx
service: name=nginx state=reloaded service: name=nginx state=reloaded
tags: deploy
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
state=restarted state=restarted
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
tags: deploy
- name: notifier | restart notifier-celery-workers - name: notifier | restart notifier-celery-workers
supervisorctl: > supervisorctl: >
...@@ -13,3 +14,4 @@ ...@@ -13,3 +14,4 @@
state=restarted state=restarted
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
tags: deploy
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
tags: deploy
- name: ora | restart ora_celery - name: ora | restart ora_celery
supervisorctl: > supervisorctl: >
...@@ -12,3 +13,4 @@ ...@@ -12,3 +13,4 @@
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
tags: deploy
- name: ora | create supervisor scripts - ora, ora_celery
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
notify:
- ora | restart ora
- ora | restart ora_celery
with_items: ['ora', 'ora_celery']
tags:
- deploy
- include: ease.yml - include: ease.yml
- name: ora | create ora application config - name: ora | create ora application config
...@@ -73,3 +84,31 @@ ...@@ -73,3 +84,31 @@
- ora | restart ora_celery - ora | restart ora_celery
tags: tags:
- deploy - deploy
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
- name: ora | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
tags: deploy
- name: ora | ensure ora is started
supervisorctl: >
name=ora
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
tags: deploy
- name: ora | ensure ora_celery is started
supervisorctl: >
name=ora_celery
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
tags: deploy
...@@ -47,17 +47,6 @@ ...@@ -47,17 +47,6 @@
- ora | restart ora_celery - ora | restart ora_celery
with_items: ora_ease_debian_pkgs with_items: ora_ease_debian_pkgs
- name: ora | create supervisor scripts - ora, ora_celery
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
notify:
- ora | restart ora
- ora | restart ora_celery
with_items: ['ora', 'ora_celery']
tags:
- deploy
- include: deploy.yml - include: deploy.yml
- name: ora | create a symlink for venv python - name: ora | create a symlink for venv python
...@@ -68,15 +57,4 @@ ...@@ -68,15 +57,4 @@
- python - python
- pip - pip
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: ora | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
- name: xqueue | stop xqueue
supervisorctl: >
name=xqueue
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=stopped
tags:
- deploy
- name: xqueue | start xqueue
supervisorctl: >
name=xqueue
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
tags:
- deploy
- name: xqueue | restart xqueue - name: xqueue | restart xqueue
supervisorctl: > supervisorctl: >
name=xqueue name={{ item }}
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=restarted
tags:
- deploy
- name: xqueue | restart xqueue consumer
supervisorctl: >
name=xqueue_consumer
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
with_items:
- xqueue
- xqueue_consumer
tags: deploy
- name: "xqueue | writing supervisor scripts - xqueue, xqueue consumer"
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
with_items: ['xqueue', 'xqueue_consumer']
tags:
- deploy
- name: xqueue | create xqueue application config - name: xqueue | create xqueue application config
template: src=xqueue.env.json.j2 dest={{ xqueue_app_dir }}/xqueue.env.json mode=0644 template: src=xqueue.env.json.j2 dest={{ xqueue_app_dir }}/xqueue.env.json mode=0644
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
...@@ -12,7 +20,6 @@ ...@@ -12,7 +20,6 @@
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
...@@ -22,7 +29,6 @@ ...@@ -22,7 +29,6 @@
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
...@@ -33,7 +39,6 @@ ...@@ -33,7 +39,6 @@
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
...@@ -43,7 +48,6 @@ ...@@ -43,7 +48,6 @@
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
...@@ -54,7 +58,6 @@ ...@@ -54,7 +58,6 @@
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
...@@ -64,6 +67,28 @@ ...@@ -64,6 +67,28 @@
sudo_user: "{{ xqueue_user }}" sudo_user: "{{ xqueue_user }}"
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
tags: tags:
- deploy - deploy
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
- name: xqueue | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
tags: deploy
- name: xqueue | ensure xqueue, consumer is running
supervisorctl: >
name={{ item }}
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
with_items:
- xqueue
- xqueue_consumer
tags: deploy
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
home="{{ xqueue_app_dir }}" home="{{ xqueue_app_dir }}"
createhome=no createhome=no
shell=/bin/false shell=/bin/false
notify:
- xqueue | restart xqueue
- name: xqueue | create xqueue app and venv dir - name: xqueue | create xqueue app and venv dir
file: > file: >
...@@ -19,6 +21,8 @@ ...@@ -19,6 +21,8 @@
state=directory state=directory
owner="{{ xqueue_user }}" owner="{{ xqueue_user }}"
group="{{ common_web_group }}" group="{{ common_web_group }}"
notify:
- xqueue | restart xqueue
with_items: with_items:
- "{{ xqueue_app_dir }}" - "{{ xqueue_app_dir }}"
- "{{ xqueue_venvs_dir }}" - "{{ xqueue_venvs_dir }}"
...@@ -27,8 +31,6 @@ ...@@ -27,8 +31,6 @@
apt: pkg={{','.join(xqueue_debian_pkgs)}} state=present apt: pkg={{','.join(xqueue_debian_pkgs)}} state=present
notify: notify:
- xqueue | restart xqueue - xqueue | restart xqueue
- xqueue | restart xqueue consumer
- name: xqueue | create xqueue db - name: xqueue | create xqueue db
mysql_db: > mysql_db: >
...@@ -38,31 +40,12 @@ ...@@ -38,31 +40,12 @@
login_password={{xqueue_auth_config.DATABASES.default.PASSWORD}} login_password={{xqueue_auth_config.DATABASES.default.PASSWORD}}
state=present state=present
encoding=utf8 encoding=utf8
notify:
- xqueue | restart xqueue
when: xqueue_create_db is defined and xqueue_create_db|lower == "yes" when: xqueue_create_db is defined and xqueue_create_db|lower == "yes"
- name: "xqueue | writing supervisor scripts - xqueue, xqueue consumer"
template: >
src={{ item }}.conf.j2 dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
with_items: ['xqueue', 'xqueue_consumer']
tags:
- deploy
- include: deploy.yml - include: deploy.yml
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: xqueue | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
- name: xqueue | create a symlink for venv python - name: xqueue | create a symlink for venv python
file: > file: >
src="{{ xqueue_venv_bin }}/{{ item }}" src="{{ xqueue_venv_bin }}/{{ item }}"
......
...@@ -20,4 +20,5 @@ ...@@ -20,4 +20,5 @@
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }} config={{ supervisor_cfg }}
state=restarted state=restarted
tags: deploy
- name: "xserver | writing supervisor script"
template: >
src=xserver.conf.j2 dest={{ supervisor_cfg_dir }}/xserver.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
tags:
- deploy
- name: xserver | checkout code - name: xserver | checkout code
git: dest={{xserver_code_dir}} repo={{xserver_source_repo}} version={{xserver_version}} git: dest={{xserver_code_dir}} repo={{xserver_source_repo}} version={{xserver_version}}
sudo_user: "{{ xserver_user }}" sudo_user: "{{ xserver_user }}"
...@@ -56,3 +63,23 @@ ...@@ -56,3 +63,23 @@
notify: xserver | restart xserver notify: xserver | restart xserver
tags: tags:
- deploy - deploy
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
- name: xserver | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
tags: deploy
- name: xserver | ensure xserver is started
supervisorctl: >
name=xserver
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
tags: deploy
...@@ -62,14 +62,6 @@ ...@@ -62,14 +62,6 @@
- "{{ secure_dir }}/files/edx_apparmor_sandbox.j2" - "{{ secure_dir }}/files/edx_apparmor_sandbox.j2"
- "usr.bin.python-sandbox.j2" - "usr.bin.python-sandbox.j2"
- name: "xserver | writing supervisor script"
template: >
src=xserver.conf.j2 dest={{ supervisor_cfg_dir }}/xserver.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
tags:
- deploy
- include: deploy.yml - include: deploy.yml
- name: xserver | enforce app-armor rules - name: xserver | enforce app-armor rules
...@@ -84,15 +76,3 @@ ...@@ -84,15 +76,3 @@
- python - python
- pip - pip
# call supervisorctl update. this reloads
# the supervisorctl config and restarts
# the services if any of the configurations
# have changed.
#
# we don't use notifications for supervisor because
# they don't work well with parameterized roles.
# See https://github.com/ansible/ansible/issues/4853
- name: xserver | update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout != ""
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