use YAML syntax for rewriting the ansible tasks

parent 16eeda55
--- ---
- name: restart notifier-scheduler - name: restart notifier-scheduler
supervisorctl: > supervisorctl:
name=notifier-scheduler name: "notifier-scheduler"
state=restarted state: restarted
config={{ supervisor_cfg }} config: "{{ supervisor_cfg }}"
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path: "{{ supervisor_ctl }}"
when: not disable_edx_services when: not disable_edx_services
- name: restart notifier-celery-workers - name: restart notifier-celery-workers
supervisorctl: > supervisorctl:
name=notifier-celery-workers name: "notifier-celery-workers"
state=restarted state: restarted
config={{ supervisor_cfg }} config: "{{ supervisor_cfg }}"
supervisorctl_path={{ supervisor_ctl }} supervisorctl_path: "{{ supervisor_ctl }}"
when: not disable_edx_services when: not disable_edx_services
--- ---
- name: Checkout code
- name: checkout code
git_2_0_1: git_2_0_1:
dest={{ NOTIFIER_CODE_DIR }} repo={{ NOTIFIER_SOURCE_REPO }} dest: "{{ NOTIFIER_CODE_DIR }}"
version={{ NOTIFIER_VERSION }} repo: "{{ NOTIFIER_SOURCE_REPO }}"
accept_hostkey=yes version: "{{ NOTIFIER_VERSION }}"
accept_hostkey: yes
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
notify: notify:
...@@ -12,48 +12,56 @@ ...@@ -12,48 +12,56 @@
- restart notifier-celery-workers - restart notifier-celery-workers
# Optional auth for git # Optional auth for git
- name: create ssh script for git (not authenticated) - name: Create ssh script for git (not authenticated)
template: > template:
src=git_ssh_noauth.sh.j2 dest={{ notifier_git_ssh }} src: "git_ssh_noauth.sh.j2"
owner={{ notifier_user }} mode=750 dest: "{{ notifier_git_ssh }}"
owner: "{{ notifier_user }}"
mode: "0750"
when: NOTIFIER_GIT_IDENTITY == "" when: NOTIFIER_GIT_IDENTITY == ""
- name: create ssh script for git (authenticated) - name: Create ssh script for git (authenticated)
template: > template:
src=git_ssh_auth.sh.j2 dest={{ notifier_git_ssh }} src: "git_ssh_auth.sh.j2"
owner={{ notifier_user }} mode=750 dest: "{{ notifier_git_ssh }}"
owner: "{{ notifier_user }}"
mode: "0750"
when: NOTIFIER_GIT_IDENTITY != "" when: NOTIFIER_GIT_IDENTITY != ""
- name: install read-only ssh key - name: Install read-only ssh key
copy: > copy:
content="{{ NOTIFIER_GIT_IDENTITY }}" dest={{ notifier_git_identity }} content: "{{ NOTIFIER_GIT_IDENTITY }}"
force=yes owner={{ notifier_user }} mode=0600 dest: "{{ notifier_git_identity }}"
force: yes
owner: "{{ notifier_user }}"
mode: "0600"
when: NOTIFIER_GIT_IDENTITY != "" when: NOTIFIER_GIT_IDENTITY != ""
- name: checkout theme - name: Checkout theme
git_2_0_1: > git_2_0_1:
dest={{ NOTIFIER_CODE_DIR }}/{{ NOTIFIER_THEME_NAME }} dest: "{{ NOTIFIER_CODE_DIR }}/{{ NOTIFIER_THEME_NAME }}"
repo={{ NOTIFIER_THEME_REPO }} repo: "{{ NOTIFIER_THEME_REPO }}"
version={{ NOTIFIER_THEME_VERSION }} version: "{{ NOTIFIER_THEME_VERSION }}"
accept_hostkey=yes accept_hostkey: yes
when: NOTIFIER_THEME_NAME != '' when: NOTIFIER_THEME_NAME != ''
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
environment: environment:
GIT_SSH: "{{ notifier_git_ssh }}" GIT_SSH: "{{ notifier_git_ssh }}"
- name: write notifier local settings - name: Write notifier local settings
template: > template:
src=settings_local.py.j2 src: "settings_local.py.j2"
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: notify:
- restart notifier-celery-workers - restart notifier-celery-workers
- name: install application requirements - name: Install application requirements
pip: pip:
requirements="{{ NOTIFIER_REQUIREMENTS_FILE }}" requirements: "{{ NOTIFIER_REQUIREMENTS_FILE }}"
virtualenv="{{ NOTIFIER_VENV_DIR }}" state=present virtualenv: "{{ NOTIFIER_VENV_DIR }}"
state: present
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
notify: notify:
...@@ -63,10 +71,13 @@ ...@@ -63,10 +71,13 @@
# 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
# place with proper perms first. # place with proper perms first.
- name: fix permissions on notifer db file - name: Fix permissions on notifer db file
file: > file:
path={{ NOTIFIER_DB_DIR }}/notifier.db state=touch owner={{ notifier_user }} group={{ NOTIFIER_WEB_USER }} path: "{{ NOTIFIER_DB_DIR }}/notifier.db"
mode=0664 state: touch
owner: "{{ notifier_user }}"
group: "{{ NOTIFIER_WEB_USER }}"
mode: "0664"
become: true become: true
notify: notify:
- restart notifier-scheduler - restart notifier-scheduler
...@@ -74,9 +85,10 @@ ...@@ -74,9 +85,10 @@
tags: tags:
- deploy - deploy
- name: syncdb - name: Syncdb
shell: > shell: "{{ NOTIFIER_VENV_DIR }}/bin/python manage.py syncdb"
cd {{ NOTIFIER_CODE_DIR }} && {{ NOTIFIER_VENV_DIR }}/bin/python manage.py syncdb args:
chdir: "{{ NOTIFIER_CODE_DIR }}"
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
environment: notifier_env_vars environment: notifier_env_vars
......
--- ---
# #
# notifier # notifier
# #
...@@ -17,138 +16,145 @@ ...@@ -17,138 +16,145 @@
# - common # - common
# - notifier # - notifier
# #
- name: install notifier specific system packages - name: Install notifier specific system packages
apt: pkg={{','.join(notifier_debian_pkgs)}} state=present apt:
name: "{{ item }}"
- name: check if incommon ca is installed state: present
command: test -e /usr/share/ca-certificates/incommon/InCommonServerCA.crt with_items: "{{ notifier_debian_pkgs }}"
- name: Check if incommon ca is installed
command: "test -e /usr/share/ca-certificates/incommon/InCommonServerCA.crt"
register: incommon_present register: incommon_present
ignore_errors: yes ignore_errors: yes
- name: create incommon ca directory - name: Create incommon ca directory
file: file:
path="/usr/share/ca-certificates/incommon" mode=2775 state=directory path: "/usr/share/ca-certificates/incommon"
state: directory
mode: "2775"
when: incommon_present|failed when: incommon_present|failed
- name: retrieve incommon server CA - name: Retrieve incommon server CA
shell: curl https://www.incommon.org/cert/repository/InCommonServerCA.txt -o /usr/share/ca-certificates/incommon/InCommonServerCA.crt get_url:
url: "https://www.incommon.org/cert/repository/InCommonServerCA.txt"
dest: "/usr/share/ca-certificates/incommon/InCommonServerCA.crt"
when: incommon_present|failed when: incommon_present|failed
- 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'
- name: update ca certs globally - name: Update ca certs globally
shell: update-ca-certificates shell: "update-ca-certificates"
- name: create notifier user {{ notifier_user }} - name: Create notifier user {{ notifier_user }}
user: > user:
name="{{ notifier_user }}" state=present shell=/bin/false name: "{{ notifier_user }}"
home="{{ notifier_app_dir }}" createhome=no state: present
shell: /bin/false
- name: create notifier app dir home: "{{ notifier_app_dir }}"
file: > createhome: no
path="{{ notifier_app_dir }}" state=directory
owner="{{ notifier_user }}" group="{{ common_web_group }}" - name: Create notifier app dir
notify: [restart notifier-scheduler, restart notifier-celery-workers] file:
path: "{{ notifier_app_dir }}"
- name: setup the notifier env state: directory
owner: "{{ notifier_user }}"
group: "{{ common_web_group }}"
notify:
- restart notifier-scheduler
- restart notifier-celery-workers
- name: Setup the notifier env
template: template:
src=notifier_env.j2 dest={{ notifier_app_dir }}/notifier_env src: "notifier_env.j2"
owner="{{ notifier_user }}" group="{{ notifier_user }}" dest: "{{ notifier_app_dir }}/notifier_env"
mode=655 owner: "{{ notifier_user }}"
group: "{{ notifier_user }}"
- name: drop a bash_profile mode: "0655"
copy: >
src=../../common/files/bash_profile - name: Drop a bash_profile
dest={{ notifier_app_dir }}/.bash_profile copy:
owner={{ notifier_user }} src: "../../common/files/bash_profile"
group={{ notifier_user }} dest: "{{ notifier_app_dir }}/.bash_profile"
owner: "{{ notifier_user }}"
- name: ensure .bashrc exists group: "{{ notifier_user }}"
shell: touch {{ notifier_app_dir }}/.bashrc
- name: Ensure .bashrc exists
file:
path: "{{ notifier_app_dir }}/.bashrc"
state: touch
become: true become: true
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
- 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'
- 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'
- name: create notifier DB directory
file:
path="{{ NOTIFIER_DB_DIR }}" mode=2775 state=directory owner={{ notifier_user }} group={{ NOTIFIER_WEB_USER }}
- name: create notifier/bin directory
file:
path="{{ notifier_app_dir }}/bin" mode=2775 state=directory owner={{ notifier_user }} group={{ notifier_user }}
- name: create notifier/.ssh directory - name: Create desired directories
file: file:
path="{{ notifier_app_dir }}/.ssh" mode=2700 state=directory owner={{ notifier_user }} group={{ notifier_user }} path: "{{ item.path }}"
state: directory
- name: create service log dir owner: "{{ item.owner }}"
file: > group: "{{ item.group }}"
path="{{ item }}" mode: "{{ item.mode }}"
state=directory
owner="syslog"
group="syslog"
with_items: with_items:
- "{{ COMMON_LOG_DIR }}/notifier" - { path: '{{ NOTIFIER_DB_DIR }}', owner: '{{ notifier_user }}', group: '{{ NOTIFIER_WEB_USER }}', mode: '2775' }
- { path: '{{ notifier_app_dir }}/bin', owner: '{{ notifier_user }}', group: '{{ notifier_user }}', mode: '2775' }
- name: write supervisord wrapper for celery workers - { path: '{{ notifier_app_dir }}/.ssh', owner: '{{ notifier_user }}', group: '{{ notifier_user }}', mode: '2700' }
template: > - { path: '{{ COMMON_LOG_DIR }}/notifier', owner: 'syslog', group: 'syslog', mode: '0664' }
src=notifier-celery-workers-supervisor.sh.j2
dest="{{ notifier_app_dir }}/notifier-celery-workers-supervisor.sh"
mode=0775
become_user: "{{ notifier_user }}"
- name: write supervisord wrapper for scheduler - name: Write supervisord wrapper for celery workers and scheduler
template: > template:
src=notifier-scheduler-supervisor.sh.j2 src: "{{ item.src }}"
dest="{{ notifier_app_dir }}/notifier-scheduler-supervisor.sh" dest: "{{ item.dest }}"
mode=0775 mode: "0775"
become_user: "{{ notifier_user }}" become_user: "{{ notifier_user }}"
with_items:
- { src: 'notifier-celery-workers-supervisor.sh.j2', dest: '{{ notifier_app_dir }}/notifier-celery-workers-supervisor.sh' }
- { src: 'notifier-scheduler-supervisor.sh.j2', dest: '{{ notifier_app_dir }}/notifier-scheduler-supervisor.sh' }
- name: write supervisord config for celery workers - name: Write supervisord config for celery workers and scheduler
template: > template:
src=edx/app/supervisor/conf.d/notifier-celery-workers.conf.j2 src: "{{ item.src }}"
dest="{{ supervisor_available_dir }}/notifier-celery-workers.conf" dest: "{{ item.dest }}"
become_user: "{{ supervisor_user }}"
- name: write supervisord config for scheduler
template: >
src=edx/app/supervisor/conf.d/notifier-scheduler.conf.j2
dest="{{ supervisor_available_dir }}/notifier-scheduler.conf"
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
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-scheduler.conf.j2', dest: '{{ supervisor_available_dir }}/notifier-scheduler.conf' }
- name: enable supervisord config for celery workers - name: Enable supervisord config for celery workers
file: > file:
src="{{ supervisor_available_dir }}/notifier-celery-workers.conf" src: "{{ supervisor_available_dir }}/notifier-celery-workers.conf"
dest="{{ supervisor_cfg_dir }}/notifier-celery-workers.conf" dest: "{{ supervisor_cfg_dir }}/notifier-celery-workers.conf"
state=link state: link
force=yes force: yes
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
notify: restart notifier-celery-workers notify:
- restart notifier-celery-workers
when: not disable_edx_services when: not disable_edx_services
- name: enable supervisord config for scheduler - name: Enable supervisord config for scheduler
file: > file:
src="{{ supervisor_available_dir }}/notifier-scheduler.conf" src: "{{ supervisor_available_dir }}/notifier-scheduler.conf"
dest="{{ supervisor_cfg_dir }}/notifier-scheduler.conf" dest: "{{ supervisor_cfg_dir }}/notifier-scheduler.conf"
state=link state: link
force=yes force: yes
become_user: "{{ supervisor_user }}" become_user: "{{ supervisor_user }}"
notify: restart notifier-scheduler notify:
- restart notifier-scheduler
when: not disable_edx_services when: not disable_edx_services
- include: deploy.yml tags=deploy - include: deploy.yml
tags:
- deploy
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