-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multitenant support to script #7
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.retry |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
THEME_BRANCH='marvel-yellow-theme-eucalyptus' | ||
THEME_REPO='https://github.com/raccoongang/themes_for_themex.io.git' | ||
|
||
CONFIGURATION_PLAYBOOKS_DIR='/encrypted/ansible/edx/playbooks' | ||
THEMEX_SCRIPT_DIR='/encrypted/ansible/edx/playbooks/themex_script' | ||
NEW_THEME_OR_JUST_UPDATE='--no-edx-update-run' | ||
|
||
if [ "$1" == "--help" ]; | ||
then | ||
echo "" | ||
echo "script parameters:" | ||
echo "'--help' : show current info" | ||
echo "'--update-run' : install new theme" | ||
echo "'--no-edx-update-run' : default script behaviour! -> just update theme repo and run update_assets" | ||
echo "" | ||
else | ||
$THEMEX_SCRIPT_DIR/update_theme.sh -brhim $THEME_BRANCH $THEME_REPO all_host_edx $CONFIGURATION_PLAYBOOKS_DIR/hosts $CONFIGURATION_PLAYBOOKS_DIR/server-vars.yml | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why https://github.com/raccoongang/themes_for_themex.io.git ? Move it to variables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sidorovdmitry |
||
|
||
if test "$#" -eq 1; | ||
then | ||
NEW_THEME_OR_JUST_UPDATE=$1 | ||
if [ "$NEW_THEME_OR_JUST_UPDATE" == "--no-edx-update-run" ]; | ||
then | ||
##### RUN OpenEdx update_assets scripts ########## | ||
$CONFIGURATION_PLAYBOOKS_DIR/update_assets_edx1.sh | ||
$CONFIGURATION_PLAYBOOKS_DIR/update_assets_edx2.sh | ||
elif [ "$NEW_THEME_OR_JUST_UPDATE" == "--edx-update-run" ]; | ||
then | ||
##### RUN OpenEdx update scripts ################# | ||
cd $CONFIGURATION_PLAYBOOKS_DIR/ | ||
$CONFIGURATION_PLAYBOOKS_DIR/update_edx1.sh | ||
$CONFIGURATION_PLAYBOOKS_DIR/update_edx2.sh | ||
fi | ||
fi | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -19,10 +19,20 @@ | |||
script_mode: "{{ mode }}" | ||||
when: mode is defined | ||||
|
||||
- name: set_fact script_mode | ||||
set_fact: | ||||
MULTITENANT_SERVER_VARS_LOCAL_LOCATION: "{{ MULTITENANT_SERVER_VARS }}" | ||||
when: MULTITENANT_SERVER_VARS is defined | ||||
|
||||
- name: set_fact script_mode | ||||
set_fact: | ||||
server_vars_path: "{{ MULTITENANT_SERVER_VARS }}" | ||||
when: MULTITENANT_SERVER_VARS is defined | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need 2 equal variables? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sidorovdmitry
|
||||
- name: Check if devstack | ||||
fail: | ||||
msg: "Playbook not applicable for devstack" | ||||
when: ((devstack.stat.exists) and (("{{ script_mode }}" == 'l') or ("{{ script_mode }}" == 'r') or ("{{ script_mode }}" == 'b') or ("{{ script_mode }}" == 'br'))) | ||||
when: devstack.stat.exists | ||||
|
||||
- name: Generate SSH keys for user ubuntu | ||||
user: | ||||
|
@@ -51,10 +61,11 @@ | |||
- role: branch | ||||
theme_branch: "{{ theme_branch }}" | ||||
theme_repo: "{{ theme_repo }}" | ||||
when: (("{{ script_mode }}" == 'br') or ("{{ script_mode }}" == 'brh') or ("{{ script_mode }}" == 'brhi')) and (script_mode is defined) and (theme_branch is defined) and (theme_repo is defined) | ||||
when: (("{{ script_mode }}" == 'br') or ("{{ script_mode }}" == 'brh') or ("{{ script_mode }}" == 'brhi') or ("{{ script_mode }}" == 'brhim')) and (script_mode is defined) and (theme_branch is defined) and (theme_repo is defined) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sidorovdmitry updated with defaults
|
||||
|
||||
- role: update-com-theme | ||||
theme_dir: "{{ theme_folder_main }}" | ||||
ignore_errors: no | ||||
SITE_THEME: "{{ theme_folder }}" | ||||
when: (theme_folder_main is defined) and (theme_folder is defined) | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,17 @@ | |
stat: | ||
path: "{{ server_vars_path }}" | ||
register: server_vars | ||
when: MULTITENANT_SERVER_VARS_LOCAL_LOCATION is undefined | ||
|
||
- name: set_fact multitenant_check | ||
set_fact: | ||
multitenant_check: True | ||
when: (MULTITENANT_SERVER_VARS_LOCAL_LOCATION is undefined) and check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
|
||
- name: Check if "{{server_vars_path}}" exist for MULTITENANT_SERVER_VARS_LOCAL_LOCATION | ||
local_action: stat path="{{ server_vars_path }}" | ||
register: server_vars | ||
when: MULTITENANT_SERVER_VARS_LOCAL_LOCATION is defined | ||
|
||
- name: Check edx-platform vars file | ||
fail: | ||
|
@@ -39,7 +50,11 @@ | |
become_method: sudo | ||
become: yes | ||
become_user: root | ||
when: check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
when: (multitenant_check is defined) and (multitenant_check) | ||
|
||
- name: Backup server-vars.yml for MULTITENANT_SERVER_VARS_LOCAL_LOCATION | ||
local_action: command cp "{{ server_vars_path }}" "{{ server_vars_path }}_{{ current_back.stdout }}" | ||
when: (MULTITENANT_SERVER_VARS_LOCAL_LOCATION is defined) and check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
|
||
- name: Ensure that server-vars contain EDXAPP_COMPREHENSIVE_THEME_DIR | ||
lineinfile: | ||
|
@@ -52,7 +67,15 @@ | |
become_method: sudo | ||
become: yes | ||
become_user: root | ||
when: check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
when: (multitenant_check is defined) and (multitenant_check) | ||
|
||
- name: Ensure that server-vars contain EDXAPP_COMPREHENSIVE_THEME_DIR for MULTITENANT_SERVER_VARS_LOCAL_LOCATION | ||
local_action: lineinfile dest="{{ server_vars_path }}" | ||
regexp='^EDXAPP_COMPREHENSIVE_THEME_DIR:' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One tab for yaml = 2 spaces There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sidorovdmitry fixed |
||
insertafter=EOF | ||
line='EDXAPP_COMPREHENSIVE_THEME_DIR{{':'}} "{{ theme_dir }}/{{ theme_folder }}"' | ||
state=present | ||
when: (MULTITENANT_SERVER_VARS_LOCAL_LOCATION is defined) and check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
|
||
- name: Ensure that server-vars contain EDXAPP_COMPREHENSIVE_THEME_DIRS | ||
lineinfile: | ||
|
@@ -65,7 +88,15 @@ | |
become_method: sudo | ||
become: yes | ||
become_user: root | ||
when: check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
when: (multitenant_check is defined) and (multitenant_check) | ||
|
||
- name: Ensure that server-vars contain EDXAPP_COMPREHENSIVE_THEME_DIRS for MULTITENANT_SERVER_VARS_LOCAL_LOCATION | ||
local_action: lineinfile dest="{{ server_vars_path }}" | ||
regexp='^EDXAPP_COMPREHENSIVE_THEME_DIRS:' | ||
insertafter=EOF | ||
line="EDXAPP_COMPREHENSIVE_THEME_DIRS{{':'}} [{{theme_dir}}]" | ||
state=present | ||
when: (MULTITENANT_SERVER_VARS_LOCAL_LOCATION is defined) and check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
|
||
- name: Ensure that server-vars contain EDXAPP_DEFAULT_SITE_THEME | ||
lineinfile: | ||
|
@@ -78,7 +109,15 @@ | |
become_method: sudo | ||
become: yes | ||
become_user: root | ||
when: check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
when: (multitenant_check is defined) and (multitenant_check) | ||
|
||
- name: Ensure that server-vars contain EDXAPP_DEFAULT_SITE_THEME for MULTITENANT_SERVER_VARS_LOCAL_LOCATION | ||
local_action: lineinfile dest="{{ server_vars_path }}" | ||
regexp='^EDXAPP_DEFAULT_SITE_THEME:' | ||
insertafter=EOF | ||
line='EDXAPP_DEFAULT_SITE_THEME{{":"}} "{{ SITE_THEME }}"' | ||
state=present | ||
when: (MULTITENANT_SERVER_VARS_LOCAL_LOCATION is defined) and check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
|
||
- name: Ensure that server-vars contain EDXAPP_ENABLE_COMPREHENSIVE_THEMING | ||
lineinfile: | ||
|
@@ -91,7 +130,15 @@ | |
become_method: sudo | ||
become: yes | ||
become_user: root | ||
when: check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
when: (multitenant_check is defined) and (multitenant_check) | ||
|
||
- name: Ensure that server-vars contain EDXAPP_ENABLE_COMPREHENSIVE_THEMING for MULTITENANT_SERVER_VARS_LOCAL_LOCATION | ||
local_action: lineinfile dest="{{server_vars_path}}" | ||
regexp='^EDXAPP_ENABLE_COMPREHENSIVE_THEMING:' | ||
insertafter=EOF | ||
line='EDXAPP_ENABLE_COMPREHENSIVE_THEMING{{":"}} true' | ||
state=present | ||
when: (MULTITENANT_SERVER_VARS_LOCAL_LOCATION is defined) and check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
|
||
- name: Get current edx-platform git branch | ||
shell: cd /edx/app/edxapp/edx-platform/ && git branch | grep \* | sed "s/(\|)//g" | sed "s/*//g" | awk '{print $NF }' | ||
|
@@ -105,5 +152,5 @@ | |
become_method: sudo | ||
become: yes | ||
become_user: root | ||
when: check_theme_root_exist.stat.exists and server_vars.stat.exists | ||
when: (multitenant_check is defined) and (multitenant_check) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not always /encrypted. It can be variable and use default value if not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sidorovdmitry
it's just an example script (example_multitenant_update_theme.sh)