5cb375645c
Add a new variable 'kolla_devmode', which when enabled, clones and bindmounts service source code into the containers. This commit adds the relevant changes for Heat, more services can be added and built upon. Usage: * Set 'kolla_devmode: yes' * Code is cloned to /opt/stack/{{ project_name }} on target node(s) * Users can develop in these repos, and simply restart the container to pick up / test changes. Debugging can be done from the host via 'remote_pdb'[0]. [0] https://pypi.python.org/pypi/remote-pdb Implements: blueprint mount-sources Change-Id: Ic0431b10d723bf84eeefc72039376fe0058dd902
293 lines
8.3 KiB
Bash
Executable File
293 lines
8.3 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This script can be used to interact with kolla via ansible.
|
|
|
|
function find_base_dir {
|
|
local real_path=$(python -c "import os;print(os.path.realpath('$0'))")
|
|
local dir_name="$(dirname "$real_path")"
|
|
if [ -z "$SNAP" ]; then
|
|
if [[ ${dir_name} == "/usr/bin" ]]; then
|
|
BASEDIR=/usr/share/kolla-ansible
|
|
elif [[ ${dir_name} == "/usr/local/bin" ]]; then
|
|
BASEDIR=/usr/local/share/kolla-ansible
|
|
elif [[ -n ${VIRTUAL_ENV} ]] && [[ ${dir_name} == "${VIRTUAL_ENV}/bin" ]]; then
|
|
BASEDIR="${VIRTUAL_ENV}/share/kolla-ansible"
|
|
else
|
|
BASEDIR="$(dirname ${dir_name})"
|
|
fi
|
|
else
|
|
BASEDIR="$SNAP/share/kolla-ansible"
|
|
fi
|
|
}
|
|
|
|
function process_cmd {
|
|
echo "$ACTION : $CMD"
|
|
$CMD
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Command failed $CMD"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function usage {
|
|
cat <<EOF
|
|
Usage: $0 COMMAND [options]
|
|
|
|
Options:
|
|
--inventory, -i <inventory_path> Specify path to ansible inventory file
|
|
--playbook, -p <playbook_path> Specify path to ansible playbook file
|
|
--configdir <config_path> Specify path to directory with globals.yml
|
|
--key -k <key_path> Specify path to ansible vault keyfile
|
|
--help, -h Show this usage information
|
|
--tags, -t <tags> Only run plays and tasks tagged with these values
|
|
--extra, -e <ansible variables> Set additional variables as key=value or YAML/JSON passed to ansible-playbook
|
|
--passwords <passwords_path> Specify path to the passwords file
|
|
--limit <host> Specify host to run plays
|
|
--verbose, -v Increase verbosity of ansible-playbook
|
|
|
|
Commands:
|
|
prechecks Do pre-deployment checks for hosts
|
|
check Do post-deployment smoke tests
|
|
mariadb_recovery Recover a completely stopped mariadb cluster
|
|
bootstrap-servers bootstrap servers with kolla deploy dependencies
|
|
destroy Destroy Kolla containers, volumes and host configuration
|
|
--include-images to also destroy Kolla images
|
|
--include-dev to also destroy dev mode repos
|
|
deploy Deploy and start all kolla containers
|
|
deploy-bifrost Deploy and start bifrost container
|
|
deploy-servers Enroll and deploy servers with bifrost
|
|
post-deploy Do post deploy on deploy node
|
|
pull Pull all images for containers (only pulls, no running container changes)
|
|
reconfigure Reconfigure OpenStack service
|
|
stop Stop Kolla containers
|
|
certificates Generate self-signed certificate for TLS *For Development Only*
|
|
upgrade Upgrades existing OpenStack Environment
|
|
genconfig Generate configuration files for enabled OpenStack services
|
|
EOF
|
|
}
|
|
|
|
function bash_completion {
|
|
cat <<EOF
|
|
--inventory -i
|
|
--playbook -p
|
|
--configdir
|
|
--key -k
|
|
--help -h
|
|
--tags -t
|
|
--extra -e
|
|
--passwords
|
|
--limit
|
|
--verbose -v
|
|
prechecks
|
|
check
|
|
mariadb_recovery
|
|
bootstrap-servers
|
|
destroy
|
|
deploy
|
|
deploy-bifrost
|
|
deploy-servers
|
|
post-deploy
|
|
pull
|
|
reconfigure
|
|
stop
|
|
certificates
|
|
upgrade
|
|
genconfig
|
|
EOF
|
|
}
|
|
|
|
SHORT_OPTS="hi:p:t:k:e:v"
|
|
LONG_OPTS="help,inventory:,playbook:,tags:,key:,extra:,verbose,configdir:,passwords:,limit:,yes-i-really-really-mean-it,include-images,include-dev"
|
|
ARGS=$(getopt -o "${SHORT_OPTS}" -l "${LONG_OPTS}" --name "$0" -- "$@") || { usage >&2; exit 2; }
|
|
|
|
eval set -- "$ARGS"
|
|
|
|
find_base_dir
|
|
|
|
INVENTORY="${BASEDIR}/ansible/inventory/all-in-one"
|
|
PLAYBOOK="${BASEDIR}/ansible/site.yml"
|
|
VERBOSITY=
|
|
EXTRA_OPTS=${EXTRA_OPTS}
|
|
CONFIG_DIR="/etc/kolla"
|
|
PASSWORDS_FILE="${CONFIG_DIR}/passwords.yml"
|
|
DANGER_CONFIRM=
|
|
INCLUDE_IMAGES=
|
|
INCLUDE_DEV=
|
|
# Serial is not recommended and disabled by default. Users can enable it by
|
|
# configuring ANSIBLE_SERIAL variable.
|
|
ANSIBLE_SERIAL=${ANSIBLE_SERIAL:-0}
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
case "$1" in
|
|
|
|
(--inventory|-i)
|
|
INVENTORY="$2"
|
|
shift 2
|
|
;;
|
|
|
|
(--playbook|-p)
|
|
PLAYBOOK="$2"
|
|
shift 2
|
|
;;
|
|
|
|
(--tags|-t)
|
|
EXTRA_OPTS="$EXTRA_OPTS --tags $2"
|
|
shift 2
|
|
;;
|
|
|
|
(--verbose|-v)
|
|
VERBOSITY="$VERBOSITY --verbose"
|
|
shift 1
|
|
;;
|
|
|
|
(--configdir)
|
|
CONFIG_DIR="$2"
|
|
shift 2
|
|
;;
|
|
|
|
(--yes-i-really-really-mean-it)
|
|
DANGER_CONFIRM="$1"
|
|
shift 1
|
|
;;
|
|
|
|
(--include-images)
|
|
INCLUDE_IMAGES="$1"
|
|
shift 1
|
|
;;
|
|
|
|
(--include-dev)
|
|
INCLUDE_DEV="$1"
|
|
shift 1
|
|
;;
|
|
|
|
(--key|-k)
|
|
VAULT_PASS_FILE="$2"
|
|
EXTRA_OPTS="$EXTRA_OPTS --vault-password-file=$VAULT_PASS_FILE"
|
|
shift 2
|
|
;;
|
|
|
|
(--extra|-e)
|
|
EXTRA_OPTS="$EXTRA_OPTS -e $2"
|
|
shift 2
|
|
;;
|
|
(--passwords)
|
|
PASSWORDS_FILE="$2"
|
|
shift 2
|
|
;;
|
|
(--limit)
|
|
EXTRA_OPTS="$EXTRA_OPTS --limit $2"
|
|
shift 2
|
|
;;
|
|
|
|
(--help|-h)
|
|
usage
|
|
shift
|
|
exit 0
|
|
;;
|
|
|
|
(--)
|
|
shift
|
|
break
|
|
;;
|
|
|
|
(*)
|
|
echo "error"
|
|
exit 3
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case "$1" in
|
|
|
|
(prechecks)
|
|
ACTION="Pre-deployment checking"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=precheck"
|
|
;;
|
|
(check)
|
|
ACTION="Post-deployment checking"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=check"
|
|
;;
|
|
(mariadb_recovery)
|
|
ACTION="Attempting to restart mariadb cluster"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=deploy -e common_run=true"
|
|
PLAYBOOK="${BASEDIR}/ansible/mariadb_recovery.yml"
|
|
;;
|
|
(destroy)
|
|
ACTION="Destroy Kolla containers, volumes and host configuration"
|
|
PLAYBOOK="${BASEDIR}/ansible/destroy.yml"
|
|
if [[ "${INCLUDE_IMAGES}" == "--include-images" ]]; then
|
|
EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_images=yes"
|
|
fi
|
|
if [[ "${INCLUDE_DEV}" == "--include-dev" ]]; then
|
|
EXTRA_OPTS="$EXTRA_OPTS -e destroy_include_dev=yes"
|
|
fi
|
|
if [[ "${DANGER_CONFIRM}" != "--yes-i-really-really-mean-it" ]]; then
|
|
cat << EOF
|
|
WARNING:
|
|
This will PERMANENTLY DESTROY all deployed kolla containers, volumes and host configuration.
|
|
There is no way to recover from this action. To confirm, please add the following option:
|
|
--yes-i-really-really-mean-it
|
|
EOF
|
|
exit 1
|
|
fi
|
|
;;
|
|
(bootstrap-servers)
|
|
ACTION="Bootstraping servers"
|
|
PLAYBOOK="${BASEDIR}/ansible/kolla-host.yml"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=bootstrap-servers"
|
|
;;
|
|
(deploy)
|
|
ACTION="Deploying Playbooks"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=deploy"
|
|
;;
|
|
(deploy-bifrost)
|
|
ACTION="Deploying Bifrost"
|
|
PLAYBOOK="${BASEDIR}/ansible/bifrost.yml"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=deploy"
|
|
;;
|
|
(deploy-servers)
|
|
ACTION="Deploying servers with bifrost"
|
|
PLAYBOOK="${BASEDIR}/ansible/bifrost.yml"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=deploy-servers"
|
|
;;
|
|
(post-deploy)
|
|
ACTION="Post-Deploying Playbooks"
|
|
PLAYBOOK="${BASEDIR}/ansible/post-deploy.yml"
|
|
;;
|
|
(pull)
|
|
ACTION="Pulling Docker images"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=pull"
|
|
;;
|
|
(upgrade)
|
|
ACTION="Upgrading OpenStack Environment"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=upgrade -e serial=${ANSIBLE_SERIAL}"
|
|
;;
|
|
(reconfigure)
|
|
ACTION="Reconfigure OpenStack service"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=reconfigure -e serial=${ANSIBLE_SERIAL}"
|
|
;;
|
|
(stop)
|
|
ACTION="Stop Kolla containers"
|
|
PLAYBOOK="${BASEDIR}/ansible/stop.yml"
|
|
;;
|
|
(certificates)
|
|
ACTION="Generate TLS Certificates"
|
|
PLAYBOOK="${BASEDIR}/ansible/certificates.yml"
|
|
;;
|
|
(genconfig)
|
|
ACTION="Generate configuration files for enabled OpenStack services"
|
|
EXTRA_OPTS="$EXTRA_OPTS -e action=config"
|
|
;;
|
|
(bash-completion)
|
|
bash_completion
|
|
exit 0
|
|
;;
|
|
(*) usage
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
CONFIG_OPTS="-e @${CONFIG_DIR}/globals.yml -e @${PASSWORDS_FILE} -e CONFIG_DIR=${CONFIG_DIR}"
|
|
CMD="ansible-playbook -i $INVENTORY $CONFIG_OPTS $EXTRA_OPTS $PLAYBOOK $VERBOSITY"
|
|
process_cmd
|