Commit 0a413f7b by Saleem Latif

Enhance ansible provisioning script to support edx/edx-themes

parent fcb4d2ff
......@@ -103,6 +103,10 @@ ECOMMERCE_PAYMENT_PROCESSOR_CONFIG:
ECOMMERCE_PLATFORM_NAME: 'Your Platform Name Here'
ECOMMERCE_THEME_SCSS: 'sass/themes/default.scss'
ECOMMERCE_COMPREHENSIVE_THEME_DIR: !!null
ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING: false
ECOMMERCE_DEFAULT_SITE_THEME: !!null
# Celery
ECOMMERCE_BROKER_USERNAME: 'celery'
ECOMMERCE_BROKER_PASSWORD: 'celery'
......@@ -114,8 +118,6 @@ ECOMMERCE_BROKER_URL: 'amqp://{{ ECOMMERCE_BROKER_USERNAME }}:{{ ECOMMERCE_BROKE
ECOMMERCE_SUPPORT_URL: 'SET_ME_PLEASE'
ECOMMERCE_DEFAULT_SITE_THEME: !!null
ECOMMERCE_SERVICE_CONFIG:
SECRET_KEY: '{{ ECOMMERCE_SECRET_KEY }}'
TIME_ZONE: '{{ ECOMMERCE_TIME_ZONE }}'
......@@ -159,7 +161,10 @@ ECOMMERCE_SERVICE_CONFIG:
BROKER_URL: '{{ ECOMMERCE_BROKER_URL }}'
DEFAULT_SITE_THEME: '{{ ECOMMERCE_DEFAULT_SITE_THEME }}'
# Theming config
COMPREHENSIVE_THEME_DIR: "{{ ECOMMERCE_COMPREHENSIVE_THEME_DIR }}"
ENABLE_COMPREHENSIVE_THEMING: "{{ ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING }}"
DEFAULT_SITE_THEME: "{{ ECOMMERCE_DEFAULT_SITE_THEME }}"
ECOMMERCE_REPOS:
......@@ -171,7 +176,6 @@ ECOMMERCE_REPOS:
DESTINATION: "{{ ecommerce_code_dir }}"
SSH_KEY: "{{ ECOMMERCE_GIT_IDENTITY }}"
ECOMMERCE_GUNICORN_WORKERS: "2"
ECOMMERCE_GUNICORN_EXTRA: ""
ECOMMERCE_GUNICORN_EXTRA_CONF: ""
......
......@@ -13,6 +13,8 @@
dependencies:
- common
- supervisor
- role: edx-themes
when: "{{ ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING }}"
- role: edx_service
edx_service_name: "{{ ecommerce_service_name }}"
edx_service_config: "{{ ECOMMERCE_SERVICE_CONFIG }}"
......
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
##
# Defaults for role themes
#
themes_service_name: "edx-themes"
themes_user: "{{ themes_service_name }}"
themes_home: "{{ COMMON_CFG_DIR }}/{{ themes_service_name }}"
themes_code_dir: "{{ themes_home }}/{{ themes_service_name }}"
THEMES_GIT_IDENTITY: !!null
THEMES_GIT_PROTOCOL: "{{ COMMON_GIT_PROTOCOL }}"
THEMES_GIT_MIRROR: "{{ COMMON_GIT_MIRROR }}"
THEMES_GIT_PATH: "{{ COMMON_GIT_PATH }}"
THEMES_REPO: "sample-themes.git"
THEMES_VERSION: "master"
THEMES_REPOS:
- PROTOCOL: "{{ THEMES_GIT_PROTOCOL }}"
DOMAIN: "{{ THEMES_GIT_MIRROR }}"
PATH: "{{ THEMES_GIT_PATH }}"
REPO: "{{ THEMES_REPO }}"
VERSION: "{{ THEMES_VERSION }}"
DESTINATION: "{{ themes_code_dir }}"
SSH_KEY: "{{ THEMES_GIT_IDENTITY }}"
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
#
#
# Tasks for role themes
#
# Overview:
#
# This role performs the repetive tasks that most edX roles
# require in our default configuration.
#
# Example play:
#
# Rather than being included in the play, this role
# is included as a dependency by other roles in the meta/main.yml
# file. The including role should add the following
# dependency definition.
#
# dependencies:
# - role: themes
# when do_setup_themes
#
# Generating an ssh key so service users can do a git
# clone over ssh for public repositories without any
# additional configuration
- name: create application user
user: >
name="{{ themes_user }}"
home="{{ themes_home }}"
createhome=yes
shell=/bin/false
generate_ssh_key=yes
tags:
- install
- install:base
# Assumes that the home directory has been created above.
# In some cases(vagrant boxes) the home directory gets created
# but does not have the current owner and group. In vagrant for
# example we were seeing it defaulting it to `root` for both.
# The item that is a blank string ("") ensures the ownership
# of the home directory is always correct before proceeding.
- name: create themes home dirs
file: >
path="{{ themes_home }}/{{ item }}"
state=directory
owner="{{ themes_user }}"
group="{{ common_web_group }}"
with_items:
- ""
tags:
- install
- install:base
- name: set git fetch.prune to ignore deleted remote refs
shell: git config --global fetch.prune true
sudo_user: "{{ themes_user }}"
when: THEMES_REPOS is defined
tags:
- install
- install:code
- name: validate git protocol
fail: msg='THEMES_REPOS.PROTOCOL must be "https" or "ssh"'
when: (item.PROTOCOL != "https") and (item.PROTOCOL != "ssh") and THEMES_REPOS is defined
with_items: THEMES_REPOS
tags:
- install
- install:code
- name: install read-only ssh key
copy: >
dest="{{ themes_home }}/.ssh/{{ item.REPO }}"
content="{{ item.SSH_KEY }}" owner={{ themes_user }}
group={{ themes_user }} mode=0600
when: item.PROTOCOL == "ssh" and THEMES_REPOS is defined
with_items: THEMES_REPOS
tags:
- install
- install:code
- name: checkout code over ssh
git_2_0_1: >
repo=git@{{ item.DOMAIN }}:{{ item.PATH }}/{{ item.REPO }}
dest={{ item.DESTINATION }} version={{ item.VERSION }}
accept_hostkey=yes key_file={{ themes_home }}/.ssh/{{ item.REPO }}
sudo_user: "{{ themes_user }}"
register: code_checkout
when: item.PROTOCOL == "ssh" and THEMES_REPOS is defined
with_items: THEMES_REPOS
tags:
- install
- install:code
- name: checkout code over https
git_2_0_1: >
repo=https://{{ item.DOMAIN }}/{{ item.PATH }}/{{ item.REPO }}
dest={{ item.DESTINATION }} version={{ item.VERSION }}
sudo_user: "{{ themes_user }}"
register: code_checkout
when: item.PROTOCOL == "https" and THEMES_REPOS is defined
with_items: THEMES_REPOS
tags:
- install
- install:code
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