forked from rcbops/jenkins-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins-opscode-fullstack
executable file
·97 lines (78 loc) · 2.68 KB
/
jenkins-opscode-fullstack
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
90
91
92
93
94
95
96
97
#!/bin/bash
#
# $1 = test repo number
#
# force a local default so this can be run on command line
DISTRELEASE=${DISTRELEASE-ubuntu-precise}
PACKAGE_REPO=${PACKAGE_REPO-proposed-packages}
[ -e $(dirname $0)/jenkins-deb-common ] || exit 1
. $(dirname $0)/jenkins-deb-common
jenkins_init
jenkins_set_vars
kvm_instance_name=${BINARY_BUILD_RELEASE}-Opscode-Fullstack
# pre-clean
sudo virsh destroy ${kvm_instance_name} || :
sleep 5
sudo lvremove -f ${LVM_ROOT}/${kvm_instance_name} || :
# this sets IP as a side-effect
get_ip $kvm_instance_name
function err_cleanup_chef() {
# $1 - name
if [ "${NOCLEAN-0}" == "1" ]; then
exit 0
fi
# Delete node and client from chef-server
ssh root@${IP} 'knife node delete $HOSTNAME -y || :'
ssh root@${IP} 'knife client delete $HOSTNAME -y || :'
sudo virsh destroy ${1}
sleep 5
sudo lvremove -f ${LVM_ROOT}/${1}
exit 1
}
MEMORY=2048000
maybe_make_kvm_instance $kvm_instance_name
trap "err_cleanup_chef ${kvm_instance_name}" SIGINT SIGTERM EXIT ERR
start_kvm_instance $kvm_instance_name ${IP} http://archive.ubuntu.com/ubuntu precise main
# Trying to fix a bug
if [ ${BINARY_BUILD_VARIANT} = "debian" ]; then
count=1
while ! ssh root@${IP} "DEBIAN_FRONTEND=noninteractive apt-get install cgroup-lite -y --force-yes"; do
if [ $count -gt 3 ]; then
echo "Unable to install cgroup-lite"
exit 1
fi
if ! ( ssh root@${IP} "/usr/bin/cgroups-mount" ); then
:
fi
sleep 2;
count=$(( count + 1 ));
done
fi
# Install system pre-reqs
if [ ${BINARY_BUILD_VARIANT} = "debian" ]; then
ssh root@${IP} "apt-get install -y wget curl build-essential automake"
else
ssh root@${IP} "yum install -y wget tar"
fi
# Install ruby/chef via opscode's fullstack installer
ssh root@${IP} "bash < <(curl -s http://s3.amazonaws.com/opscode-full-stack/install.sh)"
# Setup Hosted Chef
ssh root@${IP} 'wget http://c308412.r12.cf1.rackcdn.com/chef-server.tgz'
ssh root@${IP} 'tar -xvzf chef-server.tgz'
ssh root@${IP} 'knife configure client ./client-config'
ssh root@${IP} 'mkdir /etc/chef'
ssh root@${IP} 'cp -r ~/client-config/* /etc/chef/'
ssh root@${IP} 'knife node delete $HOSTNAME -y || :'
ssh root@${IP} 'knife client delete $HOSTNAME -y || :'
ssh root@${IP} 'chef-client'
ssh root@${IP} 'knife node run_list add $HOSTNAME role[base]'
ssh root@${IP} 'chef-client'
RET=$?
echo "RETURN code: ${RET}"
trap - SIGINT SIGTERM EXIT ERR
# Delete node and client from chef-server
ssh root@${IP} 'knife node delete $HOSTNAME -y || :'
ssh root@${IP} 'knife client delete $HOSTNAME -y || :'
sudo virsh destroy ${kvm_instance_name}
sleep 5
sudo lvremove -f ${LVM_ROOT}/${kvm_instance_name}