-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstalljenkins.sh
executable file
·192 lines (173 loc) · 6.21 KB
/
installjenkins.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/bash
################################
#
# Install Jenkins using Testkitchen
#
################################
# setup the default locations for the install
# and the default OS
#
COOKBOOKDIR=$HOME/Source/Testkitchen/Jenkins
OS="centos-6.5"
OSNODOTS=${OS//\./} # replace the "dot" in the "OS" variable
COOKBOOK="jenkins"
# destroy old instances that were lying around
cd $COOKBOOKDIR
kitchen destroy $COOKBOOK-$OSNODOTS
cd -
rm -Rf $COOKBOOKDIR
mkdir -p $COOKBOOKDIR/cookbooks
cd $COOKBOOKDIR/cookbooks
git clone https://github.com/opscode-cookbooks/jenkins.git
git clone https://github.com/opscode-cookbooks/apt.git
git clone https://github.com/opscode-cookbooks/runit.git
git clone https://github.com/opscode-cookbooks/yum.git
git clone https://github.com/opscode-cookbooks/build-essential.git
git clone https://github.com/opscode-cookbooks/yum-epel.git
git clone https://github.com/opscode-cookbooks/java.git
git clone https://github.com/opscode-cookbooks/nginx.git
#git clone https://github.com/opscode-cookbooks/artifact.git
#git clone https://github.com/opscode-cookbooks/nexus.git
git clone https://github.com/opscode-cookbooks/maven.git
git clone https://github.com/opscode-cookbooks/windows.git
git clone https://github.com/opscode-cookbooks/chef_handler.git
git clone https://github.com/opscode-cookbooks/bluepill.git
git clone https://github.com/opscode-cookbooks/rsyslog.git
git clone https://github.com/opscode-cookbooks/ohai.git
git clone https://github.com/opscode-cookbooks/ark.git
knife cookbook site download nexus
tar -xvzf nexus*.gz
knife cookbook site download artifact
tar -xvzf artifact*.gz
cd ..
#
# check if running vmware_workstation or virtualbox,
# virtualbox is assumed the default
#
# Hint, set this variable on the command line before you
# run this script if you want vmware_workstation
#
case $VAGRANT_DEFAULT_PROVIDER in
vmware_workstation|vmware_fusion)
CPUVAR=numvcpus # name of cpu for vmware vagrant
;;
virtualbox)
CPUVAR=cpus # name of cpu for virtualbox vagrant
;;
*)
CPUVAR=cpus # name of cpu for virtualbox, default value
VAGRANT_DEFAULT_PROVIDER=virtualbox # default to virtualbox if environment variable not set.
echo "VAGRANT_DEFAULT_PROVIDER, not set, setting to virtualbox as default, for this script"
;;
esac
echo `pwd`
tee $COOKBOOKDIR/.kitchen.yml >/dev/null <<EOF
# setup of testkitchen to allow install of jenkins via a chef script
# allow debug of kitchen scripts
# export KITCHEN_LOG='DEBUG'
driver:
# Getting error "NoMethodError: undefined method 'new' for Ark:Module" with Chef 12 #92
require_chef_omnibus: 11.16.0
name: vagrant
driver_config:
customize:
memory: 4048
$CPUVAR: 2
provisioner:
name: chef_solo
platforms:
- name: $OS
driver:
network:
#- ["forwarded_port", {host: 8800, guest: 80}]
- ["private_network", {ip: "192.168.56.42"}]
suites:
- name: $COOKBOOK
run_list:
- recipe[java::oracle]
- recipe[jenkins::master]
- recipe[nexus]
- recipe[maven]
attributes:
java:
oracle:
accept_oracle_download_terms: true
install_flavor: oracle
nexus:
app_server_proxy:
use_self_signed: true
version: '2.11.1-01'
external_version: '2.11.1'
checksum: 'f3c2aee1aa4bf6232b22393c1c9c1da3dfacb9ccca7ee58c85507c85748b1e67'
cli:
ssl:
verify: false
EOF
# encrypted data bag secret file, that was used
# to generate the encrypted "foo.json" file above
mkdir -p $COOKBOOKDIR
tee $COOKBOOKDIR/password.txt >/dev/null <<EOF4
ZHymME3g7lAyDZ17Q+k1RAURAcP2mdUEvVicZhA4aPNbAlH+mcXPs5GvE4bYn6zu
Ko/XE1fDLv5lV7eJhouZ2Z1u50KR82OWKZwfjAznat+6mK8mchBNYr0PQwUIe4pG
Em1Ufq3JLk1vBUO39wsGSKE1n1GX6IQ5DhGTR5jpe7Hj+qiOQTgkGZBxtL5Xk+Wu
I/9HyU9L4wj+GPF+VvybF0Zi4jU8zRIcaliwWHnUyQho/jJD7WF47VHMYSZnvSRV
h6AG97GMlnXz1TLTJc/svBMhfTgYhaxb0XZckvUuunnXbamKx40Yypu+4xgk/ksE
OMSlulOr+c5bjj1aoK5Jms4L0ckv3+ojQh2fBLs0Mj1F0zX5RtY0E3Oy0BgHApxG
rT1mqXzxhXYmLNl66x0dpMZHRnPmaNOhxLfZmgADBTVrq+UQAx+1CzjwUXcXhtAA
k775Wz4VP1+ARFOeAZBz/JymWAZ2pHy5M4INWV+elakzf8yYWmIb6tkDijKii6jB
yaI5cndwAGvlqDEyrswU3WErekNA7aakWE0d4JjWns8aW05S4AckLXNa1VYgDDWD
9OO7O6GpcPEVPPJDDKkFjKnbLFeblO9akn/ppY4EpoL5/Fhv9hjDlVIzcF744v2v
t+sYV5CnsbwcpOcrFiGDjvDfHty8Zu+eoNZQlXKIYaQ=
EOF4
tee $COOKBOOKDIR/make_encrypted_nexus_data_bag.rb >/dev/null <<EOF5
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('./password.txt')
#data = {"id" => "_wildcard", "credentials" => {:default_admin=>{:username=>"admin", :password=>"admin123"} , {:updated_admin=>{:username=>"admin", :password=>"new_password"} } }, "license" =>{:file => "base64d license file" } }
data = {
"id"=> "_wildcard",
"credentials"=> {
"default_admin"=> {
"username"=> "admin",
"password"=> "admin123"
},
"updated_admin"=> {
"username"=> "admin",
"password"=> "new_password"
},
},
"license"=> {
"file"=> "base64d license file"
}
}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('./data_bags/nexus')
File.open('./data_bags/nexus/_wildcard.json', 'w') do |f|
f.print encrypted_data.to_json
end
EOF5
tee $COOKBOOKDIR/make_encrypted_nexus_ssl_files_data_bag.rb >/dev/null <<EOF6
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('./password.txt')
#data = {"id" => "_wildcard", "credentials" => {:default_admin=>{:username=>"admin", :password=>"admin123"} , {:updated_admin=>{:username=>"admin", :password=>"new_password"} } }, "license" =>{:file => "base64d license file" } }
data = {
"id"=> "_wildcard",
"fully-qualified-domain-name"=> {
"crt"=> "base64-encoded-ssl-certificate",
"key"=> "base64-encoded-private-key"
}
}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('./data_bags/nexus_ssl_files')
File.open('./data_bags/nexus_ssl_files/_wildcard.json', 'w') do |f|
f.print encrypted_data.to_json
end
EOF6
cd $COOKBOOKDIR
# make the two encrypted databags that will be needed
ruby make_encrypted_nexus_data_bag.rb
ruby make_encrypted_nexus_ssl_files_data_bag.rb
kitchen list
kitchen create $COOKBOOK-$OSNODOTS
kitchen converge $COOKBOOK-$OSNODOTS