c88534e169
The developer documentation to run an AIO build includes a curl one-liner to run the scripts/run-aio-build.sh script. However, due to the way it sources other scripts it will fail to execute. This change sources those scripts in a way to allow them to be run from curl piped to bash and also from a local git checkout. * In run-aio-build.sh it has cd to a fresh checkout so the path can be assumed and hard-coded. * In bootstrap-aio.sh and bootstrap-ansible.sh we now test the existing behaviour first (which will work if you executed these scripts directly from a git checkout) or from a scripts subdirectory of the currrent path (which will work if you ran the curl one-liner). Example of documentation which includes the curl one-liner: http://docs.openstack.org/developer/openstack-ansible/developer-docs/quickstart-aio.html#running-an-aio-build-in-one-step The curl one-liner: curl https://raw.githubusercontent.com/openstack/openstack-ansible/master/scripts/run-aio-build.sh | sudo bash Closes-Bug: #1504198 Change-Id: I2f8629f7cc4a1b650e8b5f6c6881168c0c5abde0
130 lines
4.4 KiB
Bash
Executable File
130 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright 2014, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
# (c) 2014, Kevin Carter <kevin.carter@rackspace.com>
|
|
|
|
## Shell Opts ----------------------------------------------------------------
|
|
set -e -u -x
|
|
|
|
|
|
## Vars ----------------------------------------------------------------------
|
|
export ANSIBLE_GIT_RELEASE=${ANSIBLE_GIT_RELEASE:-"v1.9.3-1"}
|
|
export ANSIBLE_GIT_REPO=${ANSIBLE_GIT_REPO:-"https://github.com/ansible/ansible"}
|
|
export ANSIBLE_ROLE_FILE=${ANSIBLE_ROLE_FILE:-"ansible-role-requirements.yml"}
|
|
export ANSIBLE_WORKING_DIR=${ANSIBLE_WORKING_DIR:-/opt/ansible_${ANSIBLE_GIT_RELEASE}}
|
|
export SSH_DIR=${SSH_DIR:-"/root/.ssh"}
|
|
export UPDATE_ANSIBLE_REQUIREMENTS=${UPDATE_ANSIBLE_REQUIREMENTS:-"yes"}
|
|
export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:-"noninteractive"}
|
|
|
|
|
|
## Functions -----------------------------------------------------------------
|
|
info_block "Checking for required libraries." 2> /dev/null ||
|
|
source $(dirname ${0})/scripts-library.sh ||
|
|
source scripts/scripts-library.sh
|
|
|
|
## Main ----------------------------------------------------------------------
|
|
info_block "Bootstrapping System with Ansible"
|
|
|
|
# Create the ssh dir if needed
|
|
ssh_key_create
|
|
|
|
# Install the base packages
|
|
APT=`command -v apt-get` || true
|
|
YUM=`command -v yum` || true
|
|
if [[ "$APT" != "" ]]; then
|
|
apt-get update && apt-get -y install git python-all python-dev curl autoconf g++ python2.7-dev
|
|
elif [[ "$YUM" != "" ]]; then
|
|
yum check-update && yum -y install git python2 curl autoconf gcc-c++ python2-devel
|
|
fi
|
|
|
|
# If the working directory exists remove it
|
|
if [ -d "${ANSIBLE_WORKING_DIR}" ];then
|
|
rm -rf "${ANSIBLE_WORKING_DIR}"
|
|
fi
|
|
|
|
# Clone down the base ansible source
|
|
git clone "${ANSIBLE_GIT_REPO}" "${ANSIBLE_WORKING_DIR}"
|
|
pushd "${ANSIBLE_WORKING_DIR}"
|
|
git checkout "${ANSIBLE_GIT_RELEASE}"
|
|
git submodule update --init --recursive
|
|
popd
|
|
|
|
|
|
# Install pip
|
|
get_pip
|
|
|
|
# Install requirements if there are any
|
|
if [ -f "requirements.txt" ];then
|
|
pip2 install -r requirements.txt || pip install -r requirements.txt
|
|
fi
|
|
|
|
# Install ansible
|
|
pip2 install "${ANSIBLE_WORKING_DIR}" || pip install "${ANSIBLE_WORKING_DIR}"
|
|
|
|
# Update dependent roles
|
|
if [ -f "${ANSIBLE_ROLE_FILE}" ];then
|
|
# Update or create the roles manifest
|
|
if [ "${UPDATE_ANSIBLE_REQUIREMENTS}" == "yes" ];then
|
|
scripts/openstack-ansible-role-requirements.py --requirement-file ${ANSIBLE_ROLE_FILE} update
|
|
fi
|
|
# Pull all required roles.
|
|
ansible-galaxy install --role-file=${ANSIBLE_ROLE_FILE} \
|
|
--ignore-errors \
|
|
--force
|
|
fi
|
|
|
|
# Create openstack ansible wrapper tool
|
|
cat > /usr/local/bin/openstack-ansible <<EOF
|
|
#!/usr/bin/env bash
|
|
# Copyright 2014, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
#
|
|
# (c) 2014, Kevin Carter <kevin.carter@rackspace.com>
|
|
|
|
# OpenStack wrapper tool to ease the use of ansible with multiple variable files.
|
|
|
|
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${PATH}"
|
|
|
|
function info() {
|
|
echo -e "\e[0;35m\${@}\e[0m"
|
|
}
|
|
|
|
# Discover the variable files.
|
|
VAR1="\$(for i in \$(ls /etc/openstack_deploy/user_*.yml); do echo -ne "-e @\$i "; done)"
|
|
|
|
# Provide information on the discovered variables.
|
|
info "Variable files: \"\${VAR1}\""
|
|
|
|
# Run the ansible playbook command.
|
|
\$(which ansible-playbook) \${VAR1} \$@
|
|
EOF
|
|
|
|
# Ensure wrapper tool is executable
|
|
chmod +x /usr/local/bin/openstack-ansible
|
|
|
|
echo "openstack-ansible script created."
|
|
echo "System is bootstrapped and ready for use."
|