Commit faec69b4 by John Jarvis

creating options to create a sanitized ami

parent 729be3f1
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
ENABLE_DATADOG: True ENABLE_DATADOG: True
ENABLE_SPLUNKFORWARDER: False ENABLE_SPLUNKFORWARDER: False
ENABLE_NEWRELIC: False ENABLE_NEWRELIC: False
public_ami: True
roles: roles:
- aws - aws
- role: nginx - role: nginx
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
- elasticsearch - elasticsearch
- forum - forum
- { role: "xqueue", update_users: True } - { role: "xqueue", update_users: True }
- xserver - { role: xserver, when: public_ami }
- ora - ora
- discern - discern
- certs - certs
......
...@@ -43,6 +43,14 @@ fi ...@@ -43,6 +43,14 @@ fi
extra_vars_file="/var/tmp/extra-vars-$$.yml" extra_vars_file="/var/tmp/extra-vars-$$.yml"
if [[ $public_ami == "true" ]]; then
# if this is a public server do not include
# the secret var file
extra_var_arg="-e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml"
else
extra_var_arg="-e@${extra_vars_file}"
fi
if [[ -z $region ]]; then if [[ -z $region ]]; then
region="us-east-1" region="us-east-1"
fi fi
...@@ -104,11 +112,19 @@ $extra_vars ...@@ -104,11 +112,19 @@ $extra_vars
EOF EOF
if [[ $basic_auth == "true" ]]; then if [[ $basic_auth == "true" ]]; then
if [[ $public_ami == "true" ]]; then
cat << EOF_AUTH >> $extra_vars_file
NGINX_HTPASSWD_USER: edx
NGINX_HTPASSWD_PASS: edx
EOF_AUTH
else
# vars specific to provisioning added to $extra-vars # vars specific to provisioning added to $extra-vars
cat << EOF_AUTH >> $extra_vars_file cat << EOF_AUTH >> $extra_vars_file
NGINX_HTPASSWD_USER: $auth_user NGINX_HTPASSWD_USER: $auth_user
NGINX_HTPASSWD_PASS: $auth_pass NGINX_HTPASSWD_PASS: $auth_pass
EOF_AUTH EOF_AUTH
fi
fi fi
...@@ -131,25 +147,34 @@ instance_tags: ...@@ -131,25 +147,34 @@ instance_tags:
datadog: monitored datadog: monitored
root_ebs_size: $root_ebs_size root_ebs_size: $root_ebs_size
name_tag: $name_tag name_tag: $name_tag
dns_zone: $dns_zone
rabbitmq_refresh: True
elb: $elb
EOF
if [[ $public_ami != "true" ]]; then
# if this isn't a public server add the github
# user and set public_ami to false
cat << EOF >> $extra_vars_file
public_ami: False
COMMON_USER_INFO: COMMON_USER_INFO:
- name: ${github_username} - name: ${github_username}
github: true github: true
type: admin type: admin
dns_zone: $dns_zone
rabbitmq_refresh: True
USER_CMD_PROMPT: '[$name_tag] ' USER_CMD_PROMPT: '[$name_tag] '
elb: $elb
EOF EOF
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
ansible-playbook edx_provision.yml -i inventory.ini -e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml --user ubuntu -v ansible-playbook edx_provision.yml -i inventory.ini $extra_var_arg --user ubuntu -v
if [[ $server_type == "full_edx_installation" ]]; then if [[ $server_type == "full_edx_installation" ]]; then
# additional tasks that need to be run if the # additional tasks that need to be run if the
# entire edx stack is brought up from an AMI # entire edx stack is brought up from an AMI
ansible-playbook rabbitmq.yml -i "${deploy_host}," -e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml --user ubuntu ansible-playbook rabbitmq.yml -i "${deploy_host}," $extra_var_arg --user ubuntu
ansible-playbook restart_supervisor.yml -i "${deploy_host}," -e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml --user ubuntu ansible-playbook restart_supervisor.yml -i "${deploy_host}," $extra_var_arg --user ubuntu
fi fi
fi fi
...@@ -163,21 +188,22 @@ done ...@@ -163,21 +188,22 @@ done
# run non-deploy tasks for all roles # run non-deploy tasks for all roles
if [[ $reconfigure == "true" || $server_type == "full_edx_installation_from_scratch" ]]; then if [[ $reconfigure == "true" || $server_type == "full_edx_installation_from_scratch" ]]; then
cat $extra_vars_file cat $extra_vars_file
ansible-playbook edx_continuous_integration.yml -i "${deploy_host}," -e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml --user ubuntu ansible-playbook edx_continuous_integration.yml -i "${deploy_host}," $extra_var_arg --user ubuntu
fi fi
if [[ $server_type == "full_edx_installation" ]]; then if [[ $server_type == "full_edx_installation" ]]; then
# Run deploy tasks for the roles selected # Run deploy tasks for the roles selected
for i in $roles; do for i in $roles; do
if [[ ${deploy[$i]} == "true" ]]; then if [[ ${deploy[$i]} == "true" ]]; then
cat $extra_vars_file cat $extra_vars_file
ansible-playbook ${i}.yml -i "${deploy_host}," -e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml --user ubuntu --tags deploy -v ansible-playbook ${i}.yml -i "${deploy_host}," $extra_var_arg --user ubuntu --tags deploy -v
fi fi
done done
fi fi
# deploy the edx_ansible role # deploy the edx_ansible role
ansible-playbook edx_ansible.yml -i "${deploy_host}," -e@${extra_vars_file} -e@${WORKSPACE}/configuration-secure/ansible/vars/developer-sandbox.yml --user ubuntu ansible-playbook edx_ansible.yml -i "${deploy_host}," $extra_var_arg --user ubuntu
# set the hostname # set the hostname
ansible-playbook set_hostname.yml -i "${deploy_host}," -e hostname_fqdn=${deploy_host} --user ubuntu ansible-playbook set_hostname.yml -i "${deploy_host}," -e hostname_fqdn=${deploy_host} --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