Commit 78754334 by Feanil Patel Committed by GitHub

Merge pull request #3565 from edx/feanil/sandbox_16.04

Update bootstrap to be able to run a subset and run a subset when launching an instance.
parents f032546d ef65c3ce
...@@ -22,6 +22,13 @@ ...@@ -22,6 +22,13 @@
name_tag: sandbox-temp name_tag: sandbox-temp
elb: false elb: false
ec2_vpc_subnet_id: subnet-cd867aba ec2_vpc_subnet_id: subnet-cd867aba
instance_userdata: |
#!/bin/bash
set -x
set -e
export RUN_ANSIBLE=false;
wget https://raw.githubusercontent.com/edx/configuration/{{ configuration_version }}/util/install/ansible-bootstrap.sh -O - | bash;
launch_wait_time: 5
roles: roles:
- role: launch_ec2 - role: launch_ec2
keypair: "{{ keypair }}" keypair: "{{ keypair }}"
...@@ -38,19 +45,23 @@ ...@@ -38,19 +45,23 @@
assign_public_ip: yes assign_public_ip: yes
terminate_instance: true terminate_instance: true
instance_profile_name: sandbox instance_profile_name: sandbox
user_data: "{{ instance_userdata }}"
launch_ec2_wait_time: "{{ launch_wait_time }}"
- name: Configure instance(s) - name: Configure instance(s)
hosts: launched hosts: launched
become: True become: True
gather_facts: True gather_facts: False
vars: vars:
elb: false elb: False
pre_tasks: pre_tasks:
- name: Wait for cloud-init to finish - name: Wait for cloud-init to finish
wait_for: wait_for:
path: /var/log/cloud-init.log path: /var/log/cloud-init.log
timeout: 15 timeout: 15
search_regex: "final-message" search_regex: "final-message"
- name: gather_facts
setup: ""
vars_files: vars_files:
- roles/edxapp/defaults/main.yml - roles/edxapp/defaults/main.yml
- roles/xqueue/defaults/main.yml - roles/xqueue/defaults/main.yml
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
delete_on_termination: true delete_on_termination: true
zone: "{{ zone }}" zone: "{{ zone }}"
instance_profile_name: "{{ instance_profile_name }}" instance_profile_name: "{{ instance_profile_name }}"
user_data: "{{ user_data }}"
register: ec2 register: ec2
- name: Add DNS name - name: Add DNS name
...@@ -95,3 +96,7 @@ ...@@ -95,3 +96,7 @@
port: 22 port: 22
delay: 10 delay: 10
with_items: "{{ ec2.instances }}" with_items: "{{ ec2.instances }}"
- name: Wait for python to install
pause:
minutes: "{{ launch_ec2_wait_time }}"
...@@ -33,6 +33,10 @@ if [[ -z "${UPGRADE_OS}" ]]; then ...@@ -33,6 +33,10 @@ if [[ -z "${UPGRADE_OS}" ]]; then
UPGRADE_OS=false UPGRADE_OS=false
fi fi
if [[ -z "${RUN_ANSIBLE}" ]]; then
RUN_ANSIBLE=true
fi
# #
# Bootstrapping constants # Bootstrapping constants
# #
...@@ -136,35 +140,41 @@ PATH=/usr/local/bin:${PATH} ...@@ -136,35 +140,41 @@ PATH=/usr/local/bin:${PATH}
pip install setuptools=="${SETUPTOOLS_VERSION}" pip install setuptools=="${SETUPTOOLS_VERSION}"
pip install virtualenv=="${VIRTUAL_ENV_VERSION}" pip install virtualenv=="${VIRTUAL_ENV_VERSION}"
# create a new virtual env
/usr/local/bin/virtualenv "${VIRTUAL_ENV}"
PATH="${PYTHON_BIN}":${PATH} if [[ "true" == "${RUN_ANSIBLE}" ]]; then
# create a new virtual env
/usr/local/bin/virtualenv "${VIRTUAL_ENV}"
# Install the configuration repository to install PATH="${PYTHON_BIN}":${PATH}
# edx_ansible role
git clone ${CONFIGURATION_REPO} ${CONFIGURATION_DIR}
cd ${CONFIGURATION_DIR}
git checkout ${CONFIGURATION_VERSION}
make requirements
cd "${CONFIGURATION_DIR}"/playbooks/edx-east # Install the configuration repository to install
"${PYTHON_BIN}"/ansible-playbook edx_ansible.yml -i '127.0.0.1,' -c local -e "configuration_version=${CONFIGURATION_VERSION}" # edx_ansible role
git clone ${CONFIGURATION_REPO} ${CONFIGURATION_DIR}
cd ${CONFIGURATION_DIR}
git checkout ${CONFIGURATION_VERSION}
make requirements
# cleanup cd "${CONFIGURATION_DIR}"/playbooks/edx-east
rm -rf "${ANSIBLE_DIR}" "${PYTHON_BIN}"/ansible-playbook edx_ansible.yml -i '127.0.0.1,' -c local -e "configuration_version=${CONFIGURATION_VERSION}"
rm -rf "${CONFIGURATION_DIR}"
rm -rf "${VIRTUAL_ENV}"
rm -rf "${HOME}/.ansible"
cat << EOF # cleanup
****************************************************************************** rm -rf "${ANSIBLE_DIR}"
rm -rf "${CONFIGURATION_DIR}"
rm -rf "${VIRTUAL_ENV}"
rm -rf "${HOME}/.ansible"
Done bootstrapping, edx_ansible is now installed in /edx/app/edx_ansible. cat << EOF
Time to run some plays. Activate the virtual env with ******************************************************************************
> . /edx/app/edx_ansible/venvs/edx_ansible/bin/activate Done bootstrapping, edx_ansible is now installed in /edx/app/edx_ansible.
Time to run some plays. Activate the virtual env with
****************************************************************************** > . /edx/app/edx_ansible/venvs/edx_ansible/bin/activate
******************************************************************************
EOF EOF
else
mkdir -p /edx/ansible/facts.d
echo '{ "ansible_bootstrap_run": true }' > /edx/ansible/facts.d/ansible_bootstrap.json
fi
...@@ -337,7 +337,9 @@ elb: $elb ...@@ -337,7 +337,9 @@ elb: $elb
EOF EOF
if [[ $server_type != "full_edx_installation_from_scratch" ]]; then
extra_var_arg+=' -e instance_userdata="" -e launch_wait_time=0'
fi
# run the tasks to launch an ec2 instance from AMI # run the tasks to launch an ec2 instance from AMI
cat $extra_vars_file cat $extra_vars_file
run_ansible edx_provision.yml -i inventory.ini $extra_var_arg --user ubuntu run_ansible edx_provision.yml -i inventory.ini $extra_var_arg --user ubuntu
......
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