Commit 9c8baf9d by John Jarvis

rename role to have a dash instead of an underscore

parent a498e3e8
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
ENABLE_NEWRELIC: False ENABLE_NEWRELIC: False
roles: roles:
- aws - aws
- analytics_api - analytics-api
- role: datadog - role: datadog
when: COMMON_ENABLE_DATADOG when: COMMON_ENABLE_DATADOG
- role: splunkforwarder - role: splunkforwarder
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT # license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
# #
## ##
# Defaults for role analytics_api # Defaults for role analytics-api
# #
ANALYTICS_API_GIT_IDENTITY: !!null ANALYTICS_API_GIT_IDENTITY: !!null
...@@ -21,9 +21,9 @@ ANALYTICS_API_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}" ...@@ -21,9 +21,9 @@ ANALYTICS_API_PIP_EXTRA_ARGS: "-i {{ COMMON_PYPI_MIRROR_URL }}"
# #
# vars are namespace with the module name. # vars are namespace with the module name.
# #
analytics_api_role_name: "analytics_api" analytics_api_role_name: "analytics-api"
analytics_api_service_name: "analytics_api" analytics_api_service_name: "analytics-api"
analytics_api_user: "analytics_api" analytics_api_user: "analytics-api"
analytics_api_app_dir: "{{ COMMON_APP_DIR }}/{{ analytics_api_service_name }}" analytics_api_app_dir: "{{ COMMON_APP_DIR }}/{{ analytics_api_service_name }}"
analytics_api_home: "{{ COMMON_APP_DIR }}/{{ analytics_api_service_name }}" analytics_api_home: "{{ COMMON_APP_DIR }}/{{ analytics_api_service_name }}"
...@@ -57,19 +57,27 @@ ANALYTICS_API_CONFIG: ...@@ -57,19 +57,27 @@ ANALYTICS_API_CONFIG:
LANGUAGE_CODE: 'en-us' LANGUAGE_CODE: 'en-us'
# email config # email config
EMAIL_HOST: 'smtp.example.com' EMAIL_HOST: 'smtp.example.com'
EMAIL_HOST_PASSWORD: '' EMAIL_HOST_PASSWORD: ""
EMAIL_HOST_USER: '' EMAIL_HOST_USER: ""
EMAIL_PORT: 587 EMAIL_PORT: 587
API_AUTH_TOKEN: 'put-your-api-token-here' API_AUTH_TOKEN: 'put-your-api-token-here'
# db config # db config
DATABASES: DATABASES:
default: default:
ENGINE: 'django.db.backends.mysql' ENGINE: 'django.db.backends.mysql'
NAME: 'name' NAME: 'reports'
USER: 'user' USER: 'pipeline'
PASSWORD: 'password' PASSWORD: 'password'
HOST: 'localhost' HOST: 'localhost'
PORT: '3306' PORT: '3306'
analytics:
ENGINE: 'django.db.backends.mysql'
NAME: 'analytics-api'
USER: 'api'
PASSWORD: 'password'
HOST: 'localhost'
PORT: '3306'
# #
# OS packages # OS packages
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT # license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
# #
# #
# Role includes for role analytics_api # Role includes for role analytics-api
# #
# Example: # Example:
# #
...@@ -23,4 +23,4 @@ dependencies: ...@@ -23,4 +23,4 @@ dependencies:
- role: edx_service - role: edx_service
edx_role_name: "{{ analytics_api_role_name }}" edx_role_name: "{{ analytics_api_role_name }}"
edx_service_name: "{{ analytics_api_service_name }}" edx_service_name: "{{ analytics_api_service_name }}"
- supervisor - supervisor
\ No newline at end of file
...@@ -20,19 +20,19 @@ ...@@ -20,19 +20,19 @@
- name: write out app config file - name: write out app config file
template: > template: >
src=edx/app/analytics_api/analytics_api.yaml.j2 src=edx/app/analytics-api/analytics-api.yaml.j2
dest={{ analytics_api_app_dir }}/{{ analytics_api_service_name }}.yaml dest={{ COMMON_CFG_DIR }}/{{ analytics_api_service_name }}.yaml
mode=0644 owner={{ analytics_api_user }} group={{ analytics_api_user }} mode=0644 owner={{ analytics_api_user }} group={{ analytics_api_user }}
- name: write out the supervisior wrapper - name: write out the supervisior wrapper
template: > template: >
src=edx/app/analytics_api/analytics_api.sh.j2 src=edx/app/analytics-api/analytics-api.sh.j2
dest={{ analytics_api_app_dir }}/{{ analytics_api_service_name }}.sh dest={{ analytics_api_app_dir }}/{{ analytics_api_service_name }}.sh
mode=0650 owner={{ supervisor_user }} group={{ common_web_user }} mode=0650 owner={{ supervisor_user }} group={{ common_web_user }}
- name: write supervisord config - name: write supervisord config
template: > template: >
src=edx/app/supervisor/conf.d.available/analytics_api.conf.j2 src=edx/app/supervisor/conf.d.available/analytics-api.conf.j2
dest="{{ supervisor_available_dir }}/{{ analytics_api_service_name }}.conf" dest="{{ supervisor_available_dir }}/{{ analytics_api_service_name }}.conf"
owner={{ supervisor_user }} group={{ common_web_user }} mode=0644 owner={{ supervisor_user }} group={{ common_web_user }} mode=0644
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions # code style: https://github.com/edx/configuration/wiki/Ansible-Coding-Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT # license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
# #
# Tasks for role analytics_api # Tasks for role analytics-api
# #
# Overview: # Overview:
# #
...@@ -27,9 +27,9 @@ ...@@ -27,9 +27,9 @@
# ENABLE_NEWRELIC: False # ENABLE_NEWRELIC: False
# roles: # roles:
# - aws # - aws
# - analytics_api # - analytics-api
# #
# ansible-playbook -i 'api.example.com,' ./analytics_api.yml -e@/ansible/vars/deployment.yml -e@/ansible/vars/env-deployment.yml # ansible-playbook -i 'api.example.com,' ./analytics-api.yml -e@/ansible/vars/deployment.yml -e@/ansible/vars/env-deployment.yml
# #
- fail: msg="You must provide an private key for the analytics repo" - fail: msg="You must provide an private key for the analytics repo"
......
...@@ -13,21 +13,6 @@ export NEW_RELIC_APP_NAME="{{ ANALYTICS_API_NEWRELIC_APPNAME }}" ...@@ -13,21 +13,6 @@ export NEW_RELIC_APP_NAME="{{ ANALYTICS_API_NEWRELIC_APPNAME }}"
export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}" export NEW_RELIC_LICENSE_KEY="{{ NEWRELIC_LICENSE_KEY }}"
{% endif -%} {% endif -%}
# export ANALYTICS_API_CFG="{{ COMMON_CFG_DIR }}/{{ analytics_api_service_name }}.yaml"
# These blocks output environment vars that will
# eventually be replaced by loading a yaml file in
# the django settings. That file is currently also
# being created, but the var reading doesn't exist
{% for name,value in ANALYTICS_ENV_VARS.items() %}
{% if value %}
export {{ name }}="{{ value }}"
{% endif -%}
{% endfor %}
{% for name,value in ANALYTICS_DATABASES.default.items() %}
{% if value %}
export DATABASE_{{ name }}="{{ value }}"
{% endif -%}
{% endfor %}
{{ executable }} -b {{ analytics_api_gunicorn_host }}:{{ analytics_api_gunicorn_port }} -w {{ analytics_api_gunicorn_workers }} --timeout={{ analytics_api_gunicorn_timeout }} analyticsdataserver.wsgi:application {{ executable }} -b {{ analytics_api_gunicorn_host }}:{{ analytics_api_gunicorn_port }} -w {{ analytics_api_gunicorn_workers }} --timeout={{ analytics_api_gunicorn_timeout }} analyticsdataserver.wsgi:application
--- ---
# {{ ansible_managed }} # {{ ansible_managed }}
{{ ANALYTICS_API_CONFIG | to_nice_yaml }} {{ ANALYTICS_API_CONFIG | to_nice_yaml }}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
[program:{{ analytics_api_service_name }}] [program:{{ analytics_api_service_name }}]
command={{ analytics_api_app_dir }}/analytics_api.sh command={{ analytics_api_app_dir }}/analytics-api.sh
user={{ common_web_user }} user={{ common_web_user }}
directory={{ analytics_api_code_dir }} directory={{ analytics_api_code_dir }}
stdout_logfile={{ supervisor_log_dir }}/%(program_name)-stdout.log stdout_logfile={{ supervisor_log_dir }}/%(program_name)-stdout.log
......
---
# {{ ansible_managed }}
{{ ANALYTICS_API_CONFIG | to_nice_yaml }}
\ No newline at end of file
...@@ -54,13 +54,14 @@ ...@@ -54,13 +54,14 @@
with_items: with_items:
- "{{ COMMON_LOG_DIR }}/{{ edx_service_name }}" - "{{ COMMON_LOG_DIR }}/{{ edx_service_name }}"
# Replace dashes with underscores to support roles that use
# dashes (the role vars will contain underscores)
- name: install a bunch of system packages on which edx_service relies - name: install a bunch of system packages on which edx_service relies
apt: pkg={{ item }} state=present apt: pkg={{ item }} state=present
with_items: "{{ edx_service_name }}_debian_pkgs" with_items: "{{ edx_service_name.replace('-', '_') }}_debian_pkgs"
when: ansible_distribution in common_debian_variants when: ansible_distribution in common_debian_variants
- name: install a bunch of system packages on which edx_service relies - name: install a bunch of system packages on which edx_service relies
yum: pkg={{ item }} state=present yum: pkg={{ item }} state=present
with_items: "{{ edx_service_name }}_redhat_pkgs" with_items: "{{ edx_service_name.replace('-', '_') }}_redhat_pkgs"
when: ansible_distribution in common_redhat_variants when: ansible_distribution in common_redhat_variants
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
state=present state=present
encoding=utf8 encoding=utf8
when: EDXAPP_MYSQL_USER is defined when: EDXAPP_MYSQL_USER is defined
- name: setup the xqueue db user - name: setup the xqueue db user
mysql_user: > mysql_user: >
name={{ XQUEUE_MYSQL_USER }} name={{ XQUEUE_MYSQL_USER }}
...@@ -74,6 +74,29 @@ ...@@ -74,6 +74,29 @@
encoding=utf8 encoding=utf8
when: DISCERN_MYSQL_USER is defined and not disable_edx_services when: DISCERN_MYSQL_USER is defined and not disable_edx_services
- name: create databases for analytics api
mysql_db: >
db={{ item }}
state=present
encoding=utf8
with_items:
- 'reports'
- 'analytics-api'
when: analytics_api_role_name is defined
- name: create database users analytics api
mysql_user: >
name=reports
password=password
priv='reports.*:ALL'
when: analytics_api_role_name is defined
- name: create database users analytics api
mysql_user: >
name=api
password=password
priv='analytics-api.*:ALL'
when: analytics_api_role_name is defined
- name: install memcached - name: install memcached
apt: pkg=memcached state=present apt: pkg=memcached state=present
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