Skip to content

Instantly share code, notes, and snippets.

@dangtrinhnt
Created August 17, 2017 16:03
Show Gist options
  • Save dangtrinhnt/f90a0bb8127e09eef1615009b04f0d2e to your computer and use it in GitHub Desktop.
Save dangtrinhnt/f90a0bb8127e09eef1615009b04f0d2e to your computer and use it in GitHub Desktop.
Open edX's remote datastore installation
#!/bin/bash
##
## Sanity check
##
if [[ `lsb_release -rs` != "16.04" ]]; then
echo "This script is only known to work on Ubuntu 16.04, exiting...";
exit;
fi
##
## Overridable version variables in the playbooks. Each can be overridden
## individually, or with $OPENEDX_RELEASE.
##
VERSION_VARS=(
edx_platform_version
certs_version
forum_version
xqueue_version
configuration_version
demo_version
NOTIFIER_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
PROGRAMS_VERSION
)
EXTRA_VARS="-e ENABLE_ECOMMERCE=True $EXTRA_VARS"
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
# Custom Ansible variables
if [[ -f my_custom_ansible_vars.yml ]]; then
EXTRA_VARS="-e@$(pwd)/nextpath.yml $EXTRA_VARS"
fi
echo "EXTRA_VARS = $EXTRA_VARS"
# inventory file
INVENTORY="/etc/ansible/hosts"
if [[ -f inventory.ini ]]; then
INVENTORY="$(pwd)/inventory.ini"
fi
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-${OPENEDX_RELEASE-master}}
##
## Clone the configuration repository and run Ansible
##
#cd /var/tmp
#git clone https://github.com/edx/configuration
#cd configuration
#git checkout $CONFIGURATION_VERSION
#git pull
##
## Install the ansible requirements
##
#cd /var/tmp/configuration
#sudo -H pip install -r requirements.txt
##
## Run the edx_sandbox.yml playbook in the configuration/playbooks directory
##
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook ./edx-datastores.yml -i $INVENTORY -u dangtrinhnt --ask-sudo-pass $EXTRA_VARS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment