Commit 1a7fb5e4 by Michael Roytman Committed by GitHub

Merge pull request #3798 from edx/mroytman/update-notifier

Dockerfile for notifier on 16.04
parents b196e20b d7264a83
FROM edxops/xenial-common:latest
MAINTAINER edxops
WORKDIR /edx/app/edx_ansible/edx_ansible/docker/plays
ADD . /edx/app/edx_ansible/edx_ansible
COPY docker/build/notifier/ansible_overrides.yml /
RUN /edx/app/edx_ansible/venvs/edx_ansible/bin/ansible-playbook notifier.yml \
-i '127.0.0.1,' -c local \
-t 'install' \
-e@/ansible_overrides.yml
WORKDIR /edx/app
CMD ["/edx/app/supervisor/venvs/supervisor/bin/supervisord", "-n", "--configuration", "/edx/app/supervisor/supervisor/supervisord.conf"]
- name: Deploy notifier
hosts: all
sudo: True
gather_facts: True
vars:
serial_count: 1
serial: "{{ serial_count }}"
roles:
- common_vars
- docker
- notifier
---
- name: restart notifier-scheduler
supervisorctl:
name: "notifier-scheduler"
state: restarted
config: "{{ supervisor_cfg }}"
supervisorctl_path: "{{ supervisor_ctl }}"
when: not disable_edx_services
- name: restart notifier-celery-workers
supervisorctl:
name: "notifier-celery-workers"
state: restarted
config: "{{ supervisor_cfg }}"
supervisorctl_path: "{{ supervisor_ctl }}"
when: not disable_edx_services
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
accept_hostkey: yes accept_hostkey: yes
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
notify: tags:
- restart notifier-scheduler - "install"
- restart notifier-celery-workers - "install:code"
# Optional auth for git # Optional auth for git
- name: Create ssh script for git (not authenticated) - name: Create ssh script for git (not authenticated)
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
owner: "{{ notifier_user }}" owner: "{{ notifier_user }}"
mode: "0750" mode: "0750"
when: NOTIFIER_GIT_IDENTITY == "" when: NOTIFIER_GIT_IDENTITY == ""
tags:
- "install"
- "install:code"
- name: Create ssh script for git (authenticated) - name: Create ssh script for git (authenticated)
template: template:
...@@ -27,6 +30,9 @@ ...@@ -27,6 +30,9 @@
owner: "{{ notifier_user }}" owner: "{{ notifier_user }}"
mode: "0750" mode: "0750"
when: NOTIFIER_GIT_IDENTITY != "" when: NOTIFIER_GIT_IDENTITY != ""
tags:
- "install"
- "install:code"
- name: Install read-only ssh key - name: Install read-only ssh key
copy: copy:
...@@ -36,6 +42,9 @@ ...@@ -36,6 +42,9 @@
owner: "{{ notifier_user }}" owner: "{{ notifier_user }}"
mode: "0600" mode: "0600"
when: NOTIFIER_GIT_IDENTITY != "" when: NOTIFIER_GIT_IDENTITY != ""
tags:
- "install"
- "install:code"
- name: Checkout theme - name: Checkout theme
git: git:
...@@ -47,6 +56,9 @@ ...@@ -47,6 +56,9 @@
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
environment: environment:
GIT_SSH: "{{ notifier_git_ssh }}" GIT_SSH: "{{ notifier_git_ssh }}"
tags:
- "install"
- "install:code"
- name: Write notifier local settings - name: Write notifier local settings
template: template:
...@@ -54,8 +66,9 @@ ...@@ -54,8 +66,9 @@
dest: "{{ NOTIFIER_CODE_DIR }}/notifier/settings_local.py" dest: "{{ NOTIFIER_CODE_DIR }}/notifier/settings_local.py"
mode: "0555" mode: "0555"
when: NOTIFIER_THEME_NAME != '' when: NOTIFIER_THEME_NAME != ''
notify: tags:
- restart notifier-celery-workers - "install"
- "install:configuration"
- name: Install application requirements - name: Install application requirements
pip: pip:
...@@ -64,9 +77,9 @@ ...@@ -64,9 +77,9 @@
state: present state: present
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
notify: tags:
- restart notifier-scheduler - "install"
- restart notifier-celery-workers - "install:app-requirements"
# Syncdb for whatever reason always creates the file owned by www-data:www-data, and then # Syncdb for whatever reason always creates the file owned by www-data:www-data, and then
# complains it can't write because it's running as notifier. So this is to touch the file into # complains it can't write because it's running as notifier. So this is to touch the file into
...@@ -79,11 +92,10 @@ ...@@ -79,11 +92,10 @@
group: "{{ NOTIFIER_WEB_USER }}" group: "{{ NOTIFIER_WEB_USER }}"
mode: "0664" mode: "0664"
become: true become: true
notify:
- restart notifier-scheduler
- restart notifier-celery-workers
tags: tags:
- deploy - deploy
- "install"
- "install:configuration"
- name: Syncdb - name: Syncdb
shell: "{{ NOTIFIER_VENV_DIR }}/bin/python manage.py syncdb" shell: "{{ NOTIFIER_VENV_DIR }}/bin/python manage.py syncdb"
...@@ -92,6 +104,29 @@ ...@@ -92,6 +104,29 @@
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
environment: notifier_env_vars environment: notifier_env_vars
notify: when: migrate_db is defined and migrate_db|lower == "yes"
- restart notifier-scheduler tags:
- restart notifier-celery-workers - "install"
- "install:configuration"
- name: restart notifier-scheduler
supervisorctl:
name: "notifier-scheduler"
state: restarted
config: "{{ supervisor_cfg }}"
supervisorctl_path: "{{ supervisor_ctl }}"
when: not disable_edx_services
tags:
- "manage"
- "manage:start"
- name: restart notifier-celery-workers
supervisorctl:
name: "notifier-celery-workers"
state: restarted
config: "{{ supervisor_cfg }}"
supervisorctl_path: "{{ supervisor_ctl }}"
when: not disable_edx_services
tags:
- "manage"
- "manage:start"
...@@ -21,11 +21,17 @@ ...@@ -21,11 +21,17 @@
name: "{{ item }}" name: "{{ item }}"
state: present state: present
with_items: "{{ notifier_debian_pkgs }}" with_items: "{{ notifier_debian_pkgs }}"
tags:
- "install"
- "install:system-requirements"
- name: Check if incommon ca is installed - name: Check if incommon ca is installed
command: "test -e /usr/share/ca-certificates/incommon/InCommonServerCA.crt" command: "test -e /usr/share/ca-certificates/incommon/InCommonServerCA.crt"
register: incommon_present register: incommon_present
ignore_errors: yes ignore_errors: yes
tags:
- "install"
- "install:base"
- name: Create incommon ca directory - name: Create incommon ca directory
file: file:
...@@ -33,21 +39,33 @@ ...@@ -33,21 +39,33 @@
state: directory state: directory
mode: "2775" mode: "2775"
when: incommon_present|failed when: incommon_present|failed
tags:
- "install"
- "install:base"
- name: Retrieve incommon server CA - name: Retrieve incommon server CA
get_url: get_url:
url: "https://www.incommon.org/cert/repository/InCommonServerCA.txt" url: "https://www.incommon.org/cert/repository/InCommonServerCA.txt"
dest: "/usr/share/ca-certificates/incommon/InCommonServerCA.crt" dest: "/usr/share/ca-certificates/incommon/InCommonServerCA.crt"
when: incommon_present|failed when: incommon_present|failed
tags:
- "install"
- "install:base"
- name: Add InCommon ca cert - name: Add InCommon ca cert
lineinfile: lineinfile:
dest: /etc/ca-certificates.conf dest: /etc/ca-certificates.conf
regexp: 'incommon/InCommonServerCA.crt' regexp: 'incommon/InCommonServerCA.crt'
line: 'incommon/InCommonServerCA.crt' line: 'incommon/InCommonServerCA.crt'
tags:
- "install"
- "install:base"
- name: Update ca certs globally - name: Update ca certs globally
shell: "update-ca-certificates" shell: "update-ca-certificates"
tags:
- "install"
- "install:base"
- name: Create notifier user {{ notifier_user }} - name: Create notifier user {{ notifier_user }}
user: user:
...@@ -56,6 +74,9 @@ ...@@ -56,6 +74,9 @@
shell: /bin/false shell: /bin/false
home: "{{ notifier_app_dir }}" home: "{{ notifier_app_dir }}"
createhome: no createhome: no
tags:
- "install"
- "install:base"
- name: Create notifier app dir - name: Create notifier app dir
file: file:
...@@ -63,9 +84,9 @@ ...@@ -63,9 +84,9 @@
state: directory state: directory
owner: "{{ notifier_user }}" owner: "{{ notifier_user }}"
group: "{{ common_web_group }}" group: "{{ common_web_group }}"
notify: tags:
- restart notifier-scheduler - "install"
- restart notifier-celery-workers - "install:base"
- name: Setup the notifier env - name: Setup the notifier env
template: template:
...@@ -74,6 +95,9 @@ ...@@ -74,6 +95,9 @@
owner: "{{ notifier_user }}" owner: "{{ notifier_user }}"
group: "{{ notifier_user }}" group: "{{ notifier_user }}"
mode: "0655" mode: "0655"
tags:
- "install"
- "install:base"
- name: Drop a bash_profile - name: Drop a bash_profile
copy: copy:
...@@ -81,6 +105,9 @@ ...@@ -81,6 +105,9 @@
dest: "{{ notifier_app_dir }}/.bash_profile" dest: "{{ notifier_app_dir }}/.bash_profile"
owner: "{{ notifier_user }}" owner: "{{ notifier_user }}"
group: "{{ notifier_user }}" group: "{{ notifier_user }}"
tags:
- "install"
- "install:base"
- name: Ensure .bashrc exists - name: Ensure .bashrc exists
file: file:
...@@ -88,18 +115,27 @@ ...@@ -88,18 +115,27 @@
state: touch state: touch
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
tags:
- "install"
- "install:base"
- name: Add source of notifier_env to .bashrc - name: Add source of notifier_env to .bashrc
lineinfile: lineinfile:
dest: "{{ notifier_app_dir }}/.bashrc" dest: "{{ notifier_app_dir }}/.bashrc"
regexp: '. {{ notifier_app_dir }}/notifier_env' regexp: '. {{ notifier_app_dir }}/notifier_env'
line: '. {{ notifier_app_dir }}/notifier_env' line: '. {{ notifier_app_dir }}/notifier_env'
tags:
- "install"
- "install:base"
- name: Add source venv to .bashrc - name: Add source venv to .bashrc
lineinfile: lineinfile:
dest: "{{ notifier_app_dir }}/.bashrc" dest: "{{ notifier_app_dir }}/.bashrc"
regexp: '. {{ NOTIFIER_VENV_DIR }}/bin/activate' regexp: '. {{ NOTIFIER_VENV_DIR }}/bin/activate'
line: '. {{ NOTIFIER_VENV_DIR }}/bin/activate' line: '. {{ NOTIFIER_VENV_DIR }}/bin/activate'
tags:
- "install"
- "install:base"
- name: Create desired directories - name: Create desired directories
file: file:
...@@ -113,6 +149,9 @@ ...@@ -113,6 +149,9 @@
- { path: '{{ notifier_app_dir }}/bin', owner: '{{ notifier_user }}', group: '{{ notifier_user }}', mode: '2775' } - { path: '{{ notifier_app_dir }}/bin', owner: '{{ notifier_user }}', group: '{{ notifier_user }}', mode: '2775' }
- { path: '{{ notifier_app_dir }}/.ssh', owner: '{{ notifier_user }}', group: '{{ notifier_user }}', mode: '2700' } - { path: '{{ notifier_app_dir }}/.ssh', owner: '{{ notifier_user }}', group: '{{ notifier_user }}', mode: '2700' }
- { path: '{{ COMMON_LOG_DIR }}/notifier', owner: 'syslog', group: 'syslog', mode: '0664' } - { path: '{{ COMMON_LOG_DIR }}/notifier', owner: 'syslog', group: 'syslog', mode: '0664' }
tags:
- "install"
- "install:base"
- name: Write supervisord wrapper for celery workers and scheduler - name: Write supervisord wrapper for celery workers and scheduler
template: template:
...@@ -122,6 +161,9 @@ ...@@ -122,6 +161,9 @@
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
with_items: with_items:
- { src: 'notifier-scheduler-supervisor.sh.j2', dest: '{{ notifier_app_dir }}/notifier-scheduler-supervisor.sh' } - { src: 'notifier-scheduler-supervisor.sh.j2', dest: '{{ notifier_app_dir }}/notifier-scheduler-supervisor.sh' }
tags:
- "install"
- "install:configuration"
- name: Write supervisord config for celery workers and scheduler - name: Write supervisord config for celery workers and scheduler
template: template:
...@@ -132,6 +174,9 @@ ...@@ -132,6 +174,9 @@
with_items: with_items:
- { src: 'edx/app/supervisor/conf.d/notifier-celery-workers.conf.j2', dest: '{{ supervisor_available_dir }}/notifier-celery-workers.conf' } - { src: 'edx/app/supervisor/conf.d/notifier-celery-workers.conf.j2', dest: '{{ supervisor_available_dir }}/notifier-celery-workers.conf' }
- { src: 'edx/app/supervisor/conf.d/notifier-scheduler.conf.j2', dest: '{{ supervisor_available_dir }}/notifier-scheduler.conf' } - { src: 'edx/app/supervisor/conf.d/notifier-scheduler.conf.j2', dest: '{{ supervisor_available_dir }}/notifier-scheduler.conf' }
tags:
- "install"
- "install:configuration"
- name: Enable supervisord config for celery workers - name: Enable supervisord config for celery workers
file: file:
...@@ -140,9 +185,10 @@ ...@@ -140,9 +185,10 @@
state: link state: link
force: yes force: yes
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
notify:
- restart notifier-celery-workers
when: not disable_edx_services when: not disable_edx_services
tags:
- "install"
- "install:configuration"
- name: Enable supervisord config for scheduler - name: Enable supervisord config for scheduler
file: file:
...@@ -151,9 +197,10 @@ ...@@ -151,9 +197,10 @@
state: link state: link
force: yes force: yes
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
notify:
- restart notifier-scheduler
when: not disable_edx_services when: not disable_edx_services
tags:
- "install"
- "install:configuration"
- include: deploy.yml - include: deploy.yml
tags: tags:
......
...@@ -28,3 +28,4 @@ weights: ...@@ -28,3 +28,4 @@ weights:
- tools_jenkins: 8 - tools_jenkins: 8
- ecomworker: 4 - ecomworker: 4
- notes: 2 - notes: 2
- notifier: 2
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