Skip to content

Instantly share code, notes, and snippets.

@sshnaidm
Created April 12, 2018 17:08
Show Gist options
  • Save sshnaidm/83e4af1295d4f698bc3e93959277c524 to your computer and use it in GitHub Desktop.
Save sshnaidm/83e4af1295d4f698bc3e93959277c524 to your computer and use it in GitHub Desktop.
export VIRTHOST=#IP of your virthost
git clone https://github.com/openstack/tripleo-quickstart-extras
cd tripleo-quickstart-extras
git fetch https://git.openstack.org/openstack/tripleo-quickstart-extras refs/changes/29/543429/13 && git checkout FETCH_HEAD
echo -e "[virthost]\n$VIRTHOST" > /tmp/host
# Provision nodes
ansible-playbook -vv -i /tmp/host ../playbooks/libvirt-multinode.yml # -e network_vms="bridge=br0" or -e network_vms="network=default" for default NATed network
# copy libvirt_hosts file to ~/workspace on virthost
# ssh to your virthost and run this script if you have NATed network
./libvirt-reproducer.sh -w workspace -a
# libvirt-reproducer.sh:
#!/bin/bash
# See documentation for using the reproducer script:
# README-reproducer-quickstart.html
# (in the same top-level logs directory as this reproducer script).
: ${WORKSPACE:=$(mktemp -d -t reproduce-tmp.XXXXX)}
: ${CREATE_VIRTUALENV:=false}
: ${REMOVE_STACKS_KEYPAIRS:=false}
: ${NODESTACK_PREFIX:=""}
: ${AUTORUN:=0}
: ${TIMEOUT:=240}
: ${IP1:=''}
: ${IP2:=''}
: ${PRIV_KEY:="$HOME/.ssh/id_rsa"}
: ${VIRTHOST:="127.0.0.1"} # for docker proxy, see: https://gist.github.com/sshnaidm/bd75f590fcd64d932f666143495db7b4
SSH_OPTS="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
# If you set up docker proxy on your virthost, specify it here
# to set up local transparent proxy: https://gist.github.com/sshnaidm/bd75f590fcd64d932f666143495db7b4
#export NODEPOOL_DOCKER_REGISTRY_PROXY=${NODEPOOL_DOCKER_REGISTRY_PROXY:-"http://$VIRTHOST:5000"}
# Use your local centos mirror
export NODEPOOL_CENTOS_MIRROR=${NODEPOOL_CENTOS_MIRROR:-"http://mirror.centos.org/centos/"}
usage () {
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " -w, --workspace <dir>"
echo " directory where the virtualenv, inventory files, etc."
echo " are created. Defaults to creating a directory in /tmp"
echo " -v, --create-virtualenv"
echo " create a virtualenv to install Ansible and dependencies."
echo " Options to pass true/false. Defaults to true for OVB. "
echo " Defaults to false for other deployment types."
echo " -r, --remove-stacks-keypairs"
echo " delete all Heat stacks (both Multinode and OVB created) "
echo " in the tenant before deployment."
echo " Will also delete associated keypairs if they exist."
echo " Options to pass true/false.Defaults to false."
echo " -p, --nodestack-prefix"
echo " add a unique prefix for multinode and singlenode stacks"
echo " Defaults to empty."
echo " -a, --autorun"
echo " Run job on prepared environment automatically"
echo " Default is to stop after environment is ready"
echo " -t, --timeout"
echo " Timeout in minutes for the deployment"
echo " Default is 240 minutes"
echo " -h, --help print this help and exit"
}
set -e
# Input argument assignments
while [ "x$1" != "x" ]; do
case "$1" in
--workspace|-w)
WORKSPACE=$(realpath $2)
shift
;;
--create-virtualenv|-v)
CREATE_VIRTUALENV=$2
shift
;;
--remove-stacks-keypairs|-r)
REMOVE_STACKS_KEYPAIRS=$2
shift
;;
--nodestack-prefix|-p)
NODESTACK_PREFIX=$2
shift
;;
--autorun|-a)
AUTORUN=1
;;
--ip1|-i)
IP1=$2
shift
;;
--ip2|-j)
IP2=$2
shift
;;
--timeout|-t)
TIMEOUT=$2
;;
--help|-h)
usage
exit
;;
--) shift
break
;;
-*) echo "ERROR: unknown option: $1" >&2
usage >&2
exit 2
;;
*) break
;;
esac
shift
done
set -x
# Start from a clean workspace
export WORKSPACE
mkdir -p $WORKSPACE
cd $WORKSPACE
rm -rf tripleo-quickstart tripleo-quickstart-extras
# Clone quickstart and quickstart-extras
git clone https://github.com/openstack/tripleo-quickstart
git clone https://github.com/openstack/tripleo-quickstart-extras
# Workaround for not rebooting hosts, will be "-e update_subnodes=false" later
sed -i '91,$d' tripleo-quickstart-extras/roles/nodepool-setup/tasks/main.yml
# Set up a virtual env if requested
if [ "$CREATE_VIRTUALENV" = "true" ]; then
virtualenv $WORKSPACE/venv_ansible
source $WORKSPACE/venv_ansible/bin/activate
pip install --upgrade setuptools pip
pip install -Ur $WORKSPACE/tripleo-quickstart/requirements.txt
fi
if [ "$REMOVE_STACKS_KEYPAIRS" = "true" ]; then
# The cleanup templates expects there to be in a /bin dir in the workspace # from quickstart setup.
# To use the clients sourced from venv
sed -i "s#{.*/bin/##g" $WORKSPACE/tripleo-quickstart-extras/roles/ovb-manage-stack/templates/cleanup-stacks-keypairs.sh.j2
fi
# Export ZUUL_CHANGES in the Ansible host if there are changes in
# tripleo-quickstart, tripleo-quickstart-extras or tripleo-ci repos
# before running playbooks
#export ZUUL_CHANGES="openstack/tripleo-quickstart-extras:master:refs/changes/29/543429/5"
# Export our roles path so that we can use the roles from our workspace
export ANSIBLE_ROLES_PATH=$ANSIBLE_ROLES_PATH:$WORKSPACE/tripleo-quickstart/roles:$WORKSPACE/tripleo-quickstart-extras/roles
export ANSIBLE_HOST_KEY_CHECKING=False
# Export a node config for the topology you need ie:
export NODES_FILE="/config/nodes/1ctlr.yml"
ansible-playbook -i $WORKSPACE/libvirt_hosts $WORKSPACE/tripleo-quickstart-extras/playbooks/nodepool-setup.yml -e update_subnodes=false -e rdo_cloud_provider=false
# Get ansible_host
export $(awk '/subnode-0/ {print $2}' libvirt_hosts)
# Workaround for setting other than rdo cloud, will be "-e rdo_cloud_provider=false"
ssh zuul@$ansible_host -tt 'sudo sed -i "s/rdo-cloud-tripleo/some-infra-cloud/" /etc/nodepool/provider'
for h in $(grep ansible_host libvirt_hosts | awk {'print $2'} | cut -d"=" -f2); do
ssh zuul@$h -tt 'sudo sed -i "s/mirror.regionone.rdo-cloud.rdoproject.org/mirror.mtl01.inap.openstack.org/g" /etc/ci/mirror_info.sh'
done
# Create the env_vars_to_source file and copy it to the undercloud
cat >"env_vars_to_src.sh" <<EOF
#export ZUUL_CHANGES="openstack/tripleo-quickstart-extras:master:refs/changes/29/543429/5"
export NODES_FILE="/config/nodes/1ctlr.yml"
export TOCI_JOBTYPE="multinode-1ctlr-featureset010"
export REMAINING_TIME="$TIMEOUT"
export NODEPOOL_DOCKER_REGISTRY_PROXY=$NODEPOOL_DOCKER_REGISTRY_PROXY
export NODEPOOL_CENTOS_MIRROR=$NODEPOOL_CENTOS_MIRROR
export NODEPOOL_MIRROR_HOST=mirror.mtl01.inap.openstack.org
EOF
scp ${SSH_OPTS} "$WORKSPACE/env_vars_to_src.sh" zuul@$ansible_host:/home/zuul/
if [[ "$AUTORUN" == "1" ]]; then
ssh ${SSH_OPTS} zuul@$ansible_host -tt \
"screen -LS ci -h 25000 -dm bash -c 'set -m; source ~/env_vars_to_src.sh; ANSIBLE_FORCE_COLOR=true /opt/stack/tripleo-ci/toci_gate_test-oooq.sh 2>&1 | tee ~/console.log; exec bash' && screen -RD"
else
# Remove -x so that the instructions don't print twice
set +x
# Instruct the user to execute toci_gate_test-oooq.sh on the undercloud
echo "
# Now complete the test excution on the undercloud:
# ssh to the undercloud:
ssh ${SSH_OPTS} zuul@$ansible_host
# Source the environment settings file and run the toci gate script
source /home/zuul/env_vars_to_src.sh
/opt/stack/tripleo-ci/toci_gate_test-oooq.sh 2>&1 | tee console.log
# To avoid timeouts, you can start a screen session before executing the commands:
screen -S ci
"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment