Commit ffb94919 by Fred Smith Committed by Fred Smith

new xsy role

parent e4f7ce70
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
##
# Defaults for role xsy
#
#
# vars are namespace with the module name.
#
XSY_USERNAME: '1234_1234@chat.hipchat.com'
XSY_PASSWORD: 'password'
XSY_V1_TOKEN: 'HIPCHAT_V1_TOKEN'
XSY_V2_TOKEN: 'HIPCHAT_V2_TOKEN'
XSY_ROOMS: 'Hammer'
XSY_NAME: 'xsy'
XSY_HANDLE: 'xsy'
XSY_REDIS_URL: 'redis://fakeuser:redispassword@localhost:6379'
XSY_HTTPSERVER_PORT: '8081'
XSY_WORLD_WEATHER_KEY: !!null
xsy_role_name: xsy
xsy_user: xsy
xsy_app_dir: "{{ COMMON_APP_DIR }}/xsy"
xsy_code_dir: "{{ xsy_app_dir }}/xsy"
xsy_venvs_dir: "{{ xsy_app_dir }}/venvs"
xsy_venv_dir: "{{ xsy_venvs_dir }}/xsy"
xsy_venv_bin: "{{ xsy_venv_dir }}/bin"
xsy_source_repo: "https://github.com/edx/xsy.git"
xsy_version: "HEAD"
xsy_requirements_file: "{{ xsy_code_dir }}/requirements.txt"
xsy_supervisor_wrapper: "{{ xsy_app_dir }}/xsy-supervisor.sh"
xsy_environment:
WILL_USERNAME: "{{ XSY_USERNAME }}"
WILL_PASSWORD: "{{ XSY_PASSWORD }}"
WILL_V1_TOKEN: "{{ XSY_V1_TOKEN }}"
WILL_V2_TOKEN: "{{ XSY_V2_TOKEN }}"
WILL_NAME: "{{ XSY_NAME }}"
WILL_HANDLE: "{{ XSY_HANDLE }}"
WILL_REDIS_URL: "{{ XSY_REDIS_URL }}"
WILL_HTTPSERVER_PORT: "{{ XSY_HTTPSERVER_PORT }}"
WILL_WORLD_WEATHER_ONLINE_KEY: "{{ XSY_WORLD_WEATHER_KEY }}"
#
# OS packages
#
xsy_debian_pkgs: []
xsy_redhat_pkgs: []
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Handlers for role xsy
#
# Overview:
#
#
- name: restart xsy
supervisorctl: >
name=xsy
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=restarted
when: not disable_edx_services
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
##
# Role includes for role xsy
#
# Example:
#
# dependencies:
# - {
# role: my_role
# my_role_var0: "foo"
# my_role_var1: "bar"
# }
dependencies:
- supervisor
- redis
- name: setup the xsy env
template: >
src="xsy_env.j2" dest="{{ xsy_app_dir }}/xsy_env"
owner="{{ xsy_user }}" group="{{ common_web_user }}"
mode=0644
notify: restart xsy
- name: checkout the code
git: >
dest="{{ xsy_code_dir }}" repo="{{ xsy_source_repo }}"
version="{{ xsy_version }}" accept_hostkey=yes
sudo_user: "{{ xsy_user }}"
register: xsy_checkout
notify: restart xsy
- name: install the requirements
pip: >
requirements="{{ xsy_requirements_file }}"
virtualenv="{{ xsy_venv_dir }}"
state=present
extra_args="-i {{ COMMON_PYPI_MIRROR_URL }}"
sudo_user: "{{ xsy_user }}"
notify: restart xsy
- name: create the supervisor wrapper
template: >
src="{{ xsy_supervisor_wrapper|basename }}.j2"
dest="{{ xsy_supervisor_wrapper }}"
mode=0755
sudo_user: "{{ xsy_user }}"
notify: restart xsy
- name: create a supervisor config
template: >
src=xsy.conf.j2 dest="{{ supervisor_available_dir }}/xsy.conf"
owner="{{ supervisor_user }}"
group="{{ supervisor_user }}"
sudo_user: "{{ supervisor_user }}"
notify: restart xsy
- name: enable the supervisor config
file: >
src="{{ supervisor_available_dir }}/xsy.conf"
dest="{{ supervisor_cfg_dir }}/xsy.conf"
state=link
force=yes
mode=0644
sudo_user: "{{ supervisor_user }}"
when: not disable_edx_services
notify: restart xsy
- 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 xsy is started
supervisorctl: >
name=xsy
supervisorctl_path={{ supervisor_ctl }}
config={{ supervisor_cfg }}
state=started
when: not disable_edx_services
- include: tag_ec2.yml tags=deploy
when: COMMON_TAG_EC2_INSTANCE
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://github.com/edx/configuration/wiki
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role xsy
#
# Overview:
#
#
# Dependencies:
#
#
# Example play:
#
#
- name: create application user
user: >
name="{{ xsy_user }}" home="{{ xsy_app_dir }}"
createhome=no shell=/bin/false
- name: create xsy user dirs
file: >
path="{{ item }}" state=directory
owner="{{ xsy_user }}" group="{{ common_web_group }}"
with_items:
- "{{ xsy_app_dir }}"
- "{{ xsy_venvs_dir }}"
- include: deploy.yml tags=deploy
---
- name: get instance information
action: ec2_facts
tags:
- deploy
- name: tag instance
ec2_tag: resource={{ ansible_ec2_instance_id }} region={{ ansible_ec2_placement_region }}
args:
tags:
"version:xsy" : "{{ xsy_source_repo }} {{ xsy_checkout.after |truncate(7,True,'')}}"
when: xsy_checkout.after is defined
tags:
- deploy
#!/bin/bash
source {{ xsy_app_dir }}/xsy_env
cd {{ xsy_code_dir }}
{{ xsy_venv_bin }}/python run_will.py
[program:xsy]
command={{ xsy_supervisor_wrapper }}
priority=999
user={{ common_web_user }}
stdout_logfile={{ supervisor_log_dir }}/%(program_name)s-stdout.log
stderr_logfile={{ supervisor_log_dir }}/%(program_name)s-stderr.log
killasgroup=true
stopasgroup=true
stopsignal=QUIT
# {{ ansible_managed }}
{% for name,value in xsy_environment.items() -%}
{%- if value -%}
export {{ name }}="{{ value }}"
{% endif %}
{%- endfor %}
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