forked from jaypipes/os-ext-testing
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_slave.sh
89 lines (73 loc) · 3.18 KB
/
install_slave.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#! /usr/bin/env bash
# Sets up a slave Jenkins server intended to run devstack-based Jenkins jobs
set -e
THIS_DIR=`pwd`
DATA_REPO_INFO_FILE=$THIS_DIR/.data_repo_info
DATA_PATH=$THIS_DIR/data
OSEXT_PATH=$THIS_DIR/os-ext-testing
OSEXT_REPO=https://github.com/jaypipes/os-ext-testing
PUPPET_MODULE_PATH="--modulepath=$OSEXT_PATH/puppet/modules:/root/config/modules:/etc/puppet/modules"
# Install Puppet and the OpenStack Infra Config source tree
if [[ ! -e install_puppet.sh ]]; then
wget https://git.openstack.org/cgit/openstack-infra/config/plain/install_puppet.sh
sudo bash -xe install_puppet.sh
sudo git clone https://review.openstack.org/p/openstack-infra/config.git \
/root/config
sudo /bin/bash /root/config/install_modules.sh
fi
# Clone or pull the the os-ext-testing repository
if [[ ! -d $OSEXT_PATH ]]; then
echo "Cloning os-ext-testing repo..."
git clone $OSEXT_REPO $OSEXT_PATH
fi
if [[ "$PULL_LATEST_OSEXT_REPO" == "1" ]]; then
echo "Pulling latest os-ext-testing repo master..."
cd $OSEXT_PATH; git checkout master && sudo git pull; cd $THIS_DIR
fi
if [[ ! -e $DATA_PATH ]]; then
echo "Enter the URI for the location of your config data repository. Example: https://github.com/jaypipes/os-ext-testing-data"
read data_repo_uri
if [[ "$data_repo_uri" == "" ]]; then
echo "Data repository is required to proceed. Exiting."
exit 1
fi
git clone $data_repo_uri $DATA_PATH
fi
if [[ "$PULL_LATEST_DATA_REPO" == "1" ]]; then
echo "Pulling latest data repo master."
cd $DATA_PATH; git checkout master && git pull; cd $THIS_DIR;
fi
# Pulling in variables from data repository
. $DATA_PATH/vars.sh
# Validate that the upstream gerrit user and key are present in the data
# repository
if [[ -z $UPSTREAM_GERRIT_USER ]]; then
echo "Expected to find UPSTREAM_GERRIT_USER in $DATA_PATH/vars.sh. Please correct. Exiting."
exit 1
else
echo "Using upstream Gerrit user: $UPSTREAM_GERRIT_USER"
fi
if [[ ! -e "$DATA_PATH/$UPSTREAM_GERRIT_SSH_KEY_PATH" ]]; then
echo "Expected to find $UPSTREAM_GERRIT_SSH_KEY_PATH in $DATA_PATH. Please correct. Exiting."
exit 1
fi
export UPSTREAM_GERRIT_SSH_PRIVATE_KEY_CONTENTS=`cat "$DATA_PATH/$UPSTREAM_GERRIT_SSH_KEY_PATH"`
# Validate there is a Jenkins SSH key pair in the data repository
if [[ -z $JENKINS_SSH_KEY_PATH ]]; then
echo "Expected to find JENKINS_SSH_KEY_PATH in $DATA_PATH/vars.sh. Please correct. Exiting."
exit 1
elif [[ ! -e "$DATA_PATH/$JENKINS_SSH_KEY_PATH" ]]; then
echo "Expected to find Jenkins SSH key pair at $DATA_PATH/$JENKINS_SSH_KEY_PATH, but wasn't found. Please correct. Exiting."
exit 1
else
echo "Using Jenkins SSH key path: $DATA_PATH/$JENKINS_SSH_KEY_PATH"
JENKINS_SSH_PRIVATE_KEY_CONTENTS=`sudo cat $DATA_PATH/$JENKINS_SSH_KEY_PATH`
JENKINS_SSH_PUBLIC_KEY_CONTENTS=`sudo cat $DATA_PATH/$JENKINS_SSH_KEY_PATH.pub`
fi
CLASS_ARGS="ssh_key => '$JENKINS_SSH_PUBLIC_KEY_CONTENTS', "
sudo puppet apply --verbose $PUPPET_MODULE_PATH -e "class {'os_ext_testing::devstack_slave': $CLASS_ARGS }"
if [[ ! -e /opt/git ]]; then
sudo mkdir -p /opt/git
sudo -i python /opt/nodepool-scripts/cache_git_repos.py
sudo /opt/nodepool-scripts/prepare_devstack.sh
fi