---
{% include 'roles/ansible-role/templates/header.j2' %}
#
# Defaults for role {{ role_name }}
# 
{{ role_name|upper }}_GIT_IDENTITY: !!null

# depends upon Newrelic being enabled via COMMON_ENABLE_NEWRELIC
# and a key being provided via NEWRELIC_LICENSE_KEY
{{ role_name|upper }}_NEWRELIC_APPNAME: "{{ '{{ COMMON_ENVIRONMENT }}' }}-{{ '{{ COMMON_DEPLOYMENT }}' }}-{{ '{{' }} {{ role_name }}_service_name }}"
{{ role_name|upper }}_PIP_EXTRA_ARGS: "-i {{ '{{ COMMON_PYPI_MIRROR_URL }}' }}"
{{ role_name|upper }}_NGINX_PORT: 18{{ port_suffix }}
{{ role_name|upper }}_SSL_NGINX_PORT: 48{{ port_suffix }}

{{ role_name|upper }}_DEFAULT_DB_NAME: '{{ role_name }}'
{{ role_name|upper }}_MYSQL: 'localhost'
# MySQL usernames are limited to 16 characters
{{ role_name|upper }}_MYSQL_USER: '{{ role_name[:13] }}001'
{{ role_name|upper }}_MYSQL_PASSWORD: 'password'
{{ role_name|upper }}_MYSQL_OPTIONS:
  connect_timeout: 10

{{ role_name|upper }}_DATABASES:
  # rw user
  default:
    ENGINE: 'django.db.backends.mysql'
    NAME: '{{ '{{' }} {{ role_name|upper }}_DEFAULT_DB_NAME }}'
    USER: '{{ '{{' }} {{ role_name|upper }}_MYSQL_USER }}'
    PASSWORD: '{{ '{{' }} {{ role_name|upper }}_MYSQL_PASSWORD }}'
    HOST: '{{ '{{' }} {{ role_name|upper}}_MYSQL }}'
    PORT: '3306'
    ATOMIC_REQUESTS: true
    CONN_MAX_AGE: 60
    OPTIONS: '{{ '{{' }} {{ role_name|upper}}_MYSQL_OPTIONS }}'


{{ role_name|upper }}_MEMCACHE: [ 'memcache' ]

{{ role_name|upper }}_CACHES:
  default:
    BACKEND:  'django.core.cache.backends.memcached.MemcachedCache'
    KEY_PREFIX: '{{ '{{' }} {{ role_name }}_service_name }}'
    LOCATION: '{{ '{{' }} {{ role_name|upper}}_MEMCACHE }}'

{{ role_name|upper }}_VERSION: "master"
{{ role_name|upper }}_DJANGO_SETTINGS_MODULE: "{{ role_name }}.settings.production"
{{ role_name|upper }}_URL_ROOT: 'http://{{ role_name }}:18{{ port_suffix }}'
{{ role_name|upper }}_LOGOUT_URL: '{{ '{{' }} {{ role_name|upper }}_URL_ROOT }}/logout/'
{{ role_name|upper }}_OAUTH_URL_ROOT: '{{ EDXAPP_LMS_ISSUER | default("http://127.0.0.1:8000/oauth2") }}'
{{ role_name|upper }}_OIDC_LOGOUT_URL: '{{ EDXAPP_LMS_ROOT_URL | default("http://127.0.0.1:8000") }}/logout'

{{ role_name|upper }}_SECRET_KEY: 'Your secret key here'
{{ role_name|upper }}_TIME_ZONE: 'UTC'
{{ role_name|upper }}_LANGUAGE_CODE: 'en-us'

# Used to automatically configure OAuth2 Client
{{ role_name|upper }}_SOCIAL_AUTH_EDX_OIDC_KEY : '{{ role_name|lower }}-key'
{{ role_name|upper }}_SOCIAL_AUTH_EDX_OIDC_SECRET : '{{ role_name|lower }}-secret'
{{ role_name|upper }}_SOCIAL_AUTH_REDIRECT_IS_HTTPS: false

{{ role_name|upper }}_PLATFORM_NAME: 'Your Platform Name Here'

{{ role_name|upper }}_SERVICE_CONFIG:
  SECRET_KEY: '{{ '{{' }} {{ role_name|upper }}_SECRET_KEY }}'
  TIME_ZONE: '{{ '{{' }} {{ role_name|upper }}_TIME_ZONE }}'
  LANGUAGE_CODE: '{{ '{{' }} {{ role_name|upper }}_LANGUAGE_CODE }}'

  SOCIAL_AUTH_EDX_OIDC_KEY: '{{ '{{' }} {{ role_name|upper }}_SOCIAL_AUTH_EDX_OIDC_KEY }}'
  SOCIAL_AUTH_EDX_OIDC_SECRET: '{{ '{{' }} {{ role_name|upper }}_SOCIAL_AUTH_EDX_OIDC_SECRET }}'
  SOCIAL_AUTH_EDX_OIDC_ID_TOKEN_DECRYPTION_KEY: '{{ '{{' }} {{ role_name|upper }}_SOCIAL_AUTH_EDX_OIDC_SECRET }}'
  SOCIAL_AUTH_EDX_OIDC_URL_ROOT: '{{ '{{' }} {{ role_name|upper }}_OAUTH_URL_ROOT }}'
  SOCIAL_AUTH_REDIRECT_IS_HTTPS: '{{ '{{' }} {{ role_name|upper }}_SOCIAL_AUTH_REDIRECT_IS_HTTPS }}'
  SOCIAL_AUTH_EDX_OIDC_LOGOUT_URL: '{{ '{{' }} {{ role_name|upper }}_OIDC_LOGOUT_URL }}'

  STATIC_ROOT: "{{ '{{' }} COMMON_DATA_DIR }}/{{ '{{' }} {{ role_name }}_service_name }}/staticfiles"
  # db config
  DATABASES: '{{ '{{' }} {{ role_name|upper }}_DATABASES }}'
  CACHES: '{{ '{{' }} {{ role_name|upper }}_CACHES }}'

  PLATFORM_NAME: '{{ '{{' }} {{ role_name|upper }}_PLATFORM_NAME }}'


{{ role_name|upper }}_REPOS:
  - PROTOCOL: "{{ '{{' }} COMMON_GIT_PROTOCOL }}"
    DOMAIN: "{{ '{{' }} COMMON_GIT_MIRROR }}"
    PATH: "{{ '{{' }} COMMON_GIT_PATH }}"
    REPO: {{ role_name|replace('_', '-') }}.git
    VERSION: "{{ '{{' }} {{ role_name|upper }}_VERSION }}"
    DESTINATION: "{{ '{{' }} {{ role_name }}_code_dir }}"
    SSH_KEY: "{{ '{{' }} {{ role_name|upper }}_GIT_IDENTITY }}"


{{ role_name|upper }}_GUNICORN_WORKERS: "2"
{{ role_name|upper }}_GUNICORN_EXTRA: ""
{{ role_name|upper }}_GUNICORN_EXTRA_CONF: ""
{{ role_name|upper }}_GUNICORN_WORKER_CLASS: "gevent"
{{ role_name|upper }}_GUNICORN_MAX_REQUESTS: !!null

{{ role_name|upper }}_HOSTNAME: '~^((stage|prod)-)?{{ role_name|replace('_', '-') }}.*'

nginx_{{ role_name }}_gunicorn_hosts:
  - 127.0.0.1

#
# vars are namespace with the module name.
#
{{ role_name }}_role_name: {{ role_name }}
{{ role_name|lower }}_venv_dir: "{{ '{{' }} {{ role_name|lower }}_home }}/venvs/{{ '{{' }} {{ role_name|lower }}_service_name }}"

{{ role_name }}_environment:
  DJANGO_SETTINGS_MODULE: "{{ '{{' }} {{ role_name|upper }}_DJANGO_SETTINGS_MODULE }}"
  {{ role_name|upper }}_CFG: "{{ '{{' }} COMMON_CFG_DIR }}/{{ '{{' }} {{ role_name }}_service_name }}.yml"
  PATH: "{{ '{{' }} {{ role_name|lower }}_venv_dir }}/bin:{{ '{{' }} ansible_env.PATH }}"

{{ role_name }}_migration_environment:
  DJANGO_SETTINGS_MODULE: "{{ '{{' }} {{ role_name|upper }}_DJANGO_SETTINGS_MODULE }}"
  {{ role_name|upper }}_CFG: "{{ '{{' }} COMMON_CFG_DIR }}/{{ '{{' }} {{ role_name }}_service_name }}.yml"
  PATH: "{{ '{{' }} {{ role_name|lower }}_venv_dir }}/bin:{{ '{{' }} ansible_env.PATH }}"
  DB_MIGRATION_USER: "{{ '{{' }} COMMON_MYSQL_MIGRATE_USER }}"
  DB_MIGRATION_PASS: "{{ '{{' }} COMMON_MYSQL_MIGRATE_PASS }}"

{{ role_name }}_service_name: "{{ role_name }}"
{{ role_name }}_user: "{{ '{{' }} {{ role_name }}_service_name }}"
{{ role_name }}_home: "{{ '{{' }} COMMON_APP_DIR }}/{{ '{{' }} {{ role_name }}_service_name }}"
{{ role_name }}_code_dir: "{{ '{{' }} {{ role_name }}_home }}/{{ '{{' }} {{ role_name }}_service_name }}"

{{ role_name }}_gunicorn_host: "127.0.0.1"
{{ role_name }}_gunicorn_port: 8{{ port_suffix }}
{{ role_name }}_gunicorn_timeout: 300

{{ role_name }}_log_dir: "{{ '{{' }} COMMON_LOG_DIR }}/{{ '{{' }} {{ role_name }}_service_name }}"

#
# OS packages
#

{{ role_name }}_debian_pkgs:
  - libmysqlclient-dev
  - libssl-dev

{{ role_name }}_redhat_pkgs: []
