Commit 92acf889 by Arbab Nazar Committed by GitHub

Merge pull request #3145 from edx/arbab/xqueue-rewrite

use YAML syntax to write ansible tasks
parents e9ad371e db8625ee
- name: "writing supervisor scripts - xqueue, xqueue consumer"
template: >
src={{ item }}.conf.j2 dest={{ supervisor_available_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
with_items: ['xqueue', 'xqueue_consumer']
---
- name: "Writing supervisor scripts - xqueue, xqueue consumer"
template:
src: "{{ item }}.conf.j2"
dest: "{{ supervisor_available_dir }}/{{ item }}.conf"
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
mode: "0644"
with_items:
- xqueue
- xqueue_consumer
tags:
- install
- install:configuration
- name: "enabling supervisor scripts - xqueue, xqueue consumer"
file: >
src={{ supervisor_available_dir }}/{{ item }}.conf
dest={{ supervisor_cfg_dir }}/{{ item }}.conf
owner={{ supervisor_user }} group={{ common_web_user }}
mode=0644 state=link force=yes
with_items: ['xqueue', 'xqueue_consumer']
- name: "Enabling supervisor scripts - xqueue, xqueue consumer"
file:
src: "{{ supervisor_available_dir }}/{{ item }}.conf"
dest: "{{ supervisor_cfg_dir }}/{{ item }}.conf"
owner: "{{ supervisor_user }}"
group: "{{ common_web_user }}"
mode: "0644"
state: link
force: yes
with_items:
- xqueue
- xqueue_consumer
when: not disable_edx_services
tags:
- install
- install:configuration
- name: "add gunicorn configuration file"
template: >
src=xqueue_gunicorn.py.j2 dest={{ xqueue_app_dir }}/xqueue_gunicorn.py
become_user: "{{ xqueue_user }}"
tags:
- install
- install:configuration
- name: create xqueue application config
template: src=xqueue.env.json.j2 dest={{ xqueue_app_dir }}/xqueue.env.json mode=0644
become_user: "{{ xqueue_user }}"
tags:
- install
- install:configuration
- name: create xqueue auth file
template: src=xqueue.auth.json.j2 dest={{ xqueue_app_dir }}/xqueue.auth.json mode=0644
- name: Copy the configurations to the desired directory
template:
src: "{{ item.src }}"
dest: "{{ xqueue_app_dir }}/{{ item.dest }}"
mode: "{{ item.mode }}"
become_user: "{{ xqueue_user }}"
with_items:
- { src: 'xqueue_gunicorn.py.j2', dest: 'xqueue_gunicorn.py', mode: '0644' }
- { src: 'xqueue.env.json.j2', dest: 'xqueue.env.json', mode: '0644' }
- { src: 'xqueue.auth.json.j2', dest: 'xqueue.auth.json', mode: '0644' }
tags:
- install
- install:configuration
# Do A Checkout
- name: git checkout xqueue repo into xqueue_code_dir
git_2_0_1: >
dest={{ xqueue_code_dir }} repo={{ xqueue_source_repo }} version={{ xqueue_version }}
accept_hostkey=yes
- name: "Git checkout xqueue repo into {{ xqueue_code_dir }}"
git_2_0_1:
repo: "{{ xqueue_source_repo }}"
dest: "{{ xqueue_code_dir }}"
version: "{{ xqueue_version }}"
accept_hostkey: yes
become_user: "{{ xqueue_user }}"
register: xqueue_checkout
tags:
- install
- install:code
# Install the python pre requirements into {{ xqueue_venv_dir }}
- name : install python pre-requirements
pip: >
requirements="{{ xqueue_pre_requirements_file }}" virtualenv="{{ xqueue_venv_dir }}" state=present
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }} --exists-action w"
become_user: "{{ xqueue_user }}"
tags:
- install
- install:app-requirements
# Install the python post requirements into {{ xqueue_venv_dir }}
- name : install python post-requirements
pip: >
requirements="{{ xqueue_post_requirements_file }}" virtualenv="{{ xqueue_venv_dir }}" state=present
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }} --exists-action w"
# Install the python pre requirements and post requirements into {{ xqueue_venv_dir }}
- name: "Install python pre-requirements and post-requirements"
pip:
requirements: "{{ item }}"
virtualenv: "{{ xqueue_venv_dir }}"
state: present
extra_args: "-i {{ COMMON_PYPI_MIRROR_URL }} --exists-action w"
become_user: "{{ xqueue_user }}"
with_items:
- "{{ xqueue_pre_requirements_file }}"
- "{{ xqueue_post_requirements_file }}"
tags:
- install
- install:app-requirements
# If there is a common user for migrations run migrations using his username
# and credentials. If not we use the xqueue mysql user
- name: migrate
shell: >
SERVICE_VARIANT=xqueue {{ xqueue_venv_bin }}/django-admin.py migrate --noinput --settings=xqueue.aws_migrate --pythonpath={{ xqueue_code_dir }}
- name: Migrate
shell: "SERVICE_VARIANT=xqueue {{ xqueue_venv_bin }}/django-admin.py migrate --noinput --settings=xqueue.aws_migrate --pythonpath={{ xqueue_code_dir }}"
become_user: "{{ xqueue_user }}"
environment:
DB_MIGRATION_USER: "{{ COMMON_MYSQL_MIGRATE_USER }}"
......@@ -87,9 +85,8 @@
- migrate
- migrate:db
- name: create users
shell: >
SERVICE_VARIANT=xqueue {{ xqueue_venv_bin }}/django-admin.py update_users --settings=xqueue.aws_settings --pythonpath={{ xqueue_code_dir }}
- name: Create users
shell: "SERVICE_VARIANT=xqueue {{ xqueue_venv_bin }}/django-admin.py update_users --settings=xqueue.aws_settings --pythonpath={{ xqueue_code_dir }}"
become_user: "{{ xqueue_user }}"
tags:
- manage
......@@ -100,45 +97,45 @@
# the services if any of the configurations
# have changed.
#
- name: update supervisor configuration
- name: Update supervisor configuration
shell: "{{ supervisor_ctl }} -c {{ supervisor_cfg }} update"
register: supervisor_update
changed_when: supervisor_update.stdout is defined and supervisor_update.stdout != ""
when: not disable_edx_services
- name: ensure xqueue, consumer is running
supervisorctl: >
name={{ item }}
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
- name: Ensure xqueue, consumer is running
supervisorctl:
name: "{{ item }}"
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
state: started
with_items:
- xqueue
- xqueue_consumer
- xqueue
- xqueue_consumer
when: not disable_edx_services
tags:
- manage
- manage:start
- name: create a symlink for venv python
file: >
src="{{ xqueue_venv_bin }}/{{ item }}"
dest={{ COMMON_BIN_DIR }}/{{ item }}.xqueue
state=link
- name: Create a symlink for venv python
file:
src: "{{ xqueue_venv_bin }}/{{ item }}"
dest: "{{ COMMON_BIN_DIR }}/{{ item }}.xqueue"
state: link
with_items:
- python
- pip
- python
- pip
tags:
- install
- install:app-requirements
- name: restart xqueue
supervisorctl: >
name={{ item }}
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=restarted
- name: Restart xqueue
supervisorctl:
name: "{{ item }}"
supervisorctl_path: "{{ supervisor_ctl }}"
config: "{{ supervisor_cfg }}"
state: restarted
when: not disable_edx_services
with_items:
- xqueue
- xqueue_consumer
- xqueue
- xqueue_consumer
......@@ -5,23 +5,22 @@
# Check out xqueue repo to {{ xqueue_code_dir }}
#
#
- name: create application user
user: >
name="{{ xqueue_user }}"
home="{{ xqueue_app_dir }}"
createhome=no
shell=/bin/false
- name: Create application user
user:
name: "{{ xqueue_user }}"
home: "{{ xqueue_app_dir }}"
createhome: no
shell: /bin/false
tags:
- install
- install:base
- name: create xqueue app and venv dir
file: >
path="{{ item }}"
state=directory
owner="{{ xqueue_user }}"
group="{{ common_web_group }}"
- name: Create xqueue app and venv dir
file:
path: "{{ item }}"
state: directory
owner: "{{ xqueue_user }}"
group: "{{ common_web_group }}"
with_items:
- "{{ xqueue_app_dir }}"
- "{{ xqueue_venvs_dir }}"
......@@ -29,14 +28,15 @@
- install
- install:base
- name: install a bunch of system packages on which xqueue relies
apt: pkg={{','.join(xqueue_debian_pkgs)}} state=present
- name: Install a bunch of system packages on which xqueue relies
apt:
name: "{{ item }}"
state: present
with_items: "{{ xqueue_debian_pkgs }}"
tags:
- install
- install:system-requirements
- include: deploy.yml tags=deploy
- include: deploy.yml
tags:
- deploy
\ No newline at end of file
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