-
Notifications
You must be signed in to change notification settings - Fork 4
/
installoracle.sh
executable file
·194 lines (177 loc) · 6.54 KB
/
installoracle.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
192
193
194
#!/bin/bash
################################
#
# Install Oracle using Testkitchen
#
################################
# setup the default locations for the install
# and the default OS
#
COOKBOOKDIR=$HOME/Source/Testkitchen/Oracle
OS="centos-6.5"
OSNODOTS=${OS//\./} # replace the "dot" in the "OS" variable
COOKBOOK="oracle"
# this is the location of the Oracle binaries
# you will need an oracle account to obtain these
#
ORACLEBIN=$HOME/Source/Chef/Oraclebin
# Location of the Oracle binaries inside the virtual machine
#
VMORACLEBIN=/opt/applications/chef/Oraclebin
# destroy old instances that were lying around
#
cd $COOKBOOKDIR
kitchen destroy $COOKBOOK-$OSNODOTS
cd -
rm -Rf $COOKBOOKDIR
mkdir -p $COOKBOOKDIR/cookbooks
cd $COOKBOOKDIR/cookbooks
# download the oracle cookbook
#
#git clone https://github.com/edelight/chef-solo-search.git
git clone https://github.com/aririikonen/oracle
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
# create the config file for test kitchen
#
tee $COOKBOOKDIR/.kitchen.yml >/dev/null <<EOF
# setup of testkitchen to allow install of oracle via a chef script
# allow debug of kitchen scripts
# export KITCHEN_LOG='DEBUG'
driver:
name: vagrant
driver_config:
synced_folders: [ [ "$ORACLEBIN","$VMORACLEBIN", "create: false, disabled: false" ] ]
customize:
memory: 4048
$CPUVAR: 2
provisioner:
name: chef_solo
platforms:
- name: $OS
suites:
- name: $COOKBOOK
data_bag_path: "$COOKBOOKDIR/data_bags"
role_path: "$COOKBOOKDIR/roles"
encrypted_data_bag_secret_key_path: "$COOKBOOKDIR/password.txt"
run_list:
- role[oracle_full_test]
- role[oracle_createdb]
- role[ora_cli_quickstart]
attributes:
EOF
# create the oracle role, for chef install of oracle
# the location of the oracle binaries below, is
# inside the virtual machine, not on your local
# workstation. Normally you should not change these
# locations. They are relative to the "synced_folders" above
mkdir -p $COOKBOOKDIR/roles
tee $COOKBOOKDIR/roles/oracle_full_test.rb >/dev/null <<EOF1
name "ora_quickstart"
description "Role applied to Oracle quickstart test machines."
run_list 'recipe[oracle]', 'recipe[oracle::logrotate_alert_log]', 'recipe[oracle::logrotate_listener]', 'recipe[oracle::createdb]'
override_attributes :oracle => {:rdbms => {:latest_patch => {:url => 'file://$VMORACLEBIN/11.2/p16619892_112030_Linux-x86-64.zip'}, :opatch_update_url => 'file://$VMORACLEBIN/11.2/p6880880_112000_Linux-x86-64.zip', :install_files => ['file://$VMORACLEBIN/11.2/p10404530_112030_Linux-x86-64_1of7.zip', 'file://$VMORACLEBIN/11.2/p10404530_112030_Linux-x86-64_2of7.zip','file://$VMORACLEBIN/11.2/p10404530_112030_Linux-x86-64_4of7.zip']}}
EOF1
# this sets the oracle db password to "oraclesecret"
# the encrypted databag uses the shared secret in the
# file "password.txt" that follows
mkdir -p $COOKBOOKDIR/data_bags/oracle
tee $COOKBOOKDIR/data_bags/oracle/foo.json >/dev/null <<EOF2
{
"id":"foo",
"pw":{
"encrypted_data":"DBmrU40EVl9Z15rGIGwSnJ4IxCFieu+B0l7D3HAsdqU=\n",
"iv":"o3ipr3zynuSunRNBdG8RDA==\n",
"version":1,
"cipher":"aes-256-cbc"
}
}
EOF2
mkdir -p $COOKBOOKDIR/roles
tee $COOKBOOKDIR/roles/oracle_createdb.rb >/dev/null <<EOF3
name "ora_createdb"
description "Role to create a db."
run_list 'recipe[oracle::createdb]'
override_attributes :oracle => {:rdbms => {:dbs => {:FOO => false}}}
EOF3
# 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
#
# Oracle client components
#
mkdir -p $COOKBOOKDIR/roles
tee $COOKBOOKDIR/roles/ora_cli_quickstart.rb >/dev/null <<EOF5
name "ora_cli_quickstart"
description "Role applied to Oracle Client quickstart test machines."
run_list 'recipe[oracle::oracli]'
override_attributes :oracle => {:client => {:latest_patch => {:url => 'file://$VMORACLEBIN/11.2/p16619892_112030_Linux-x86-64.zip'}, :opatch_update_url => 'file://$VMORACLEBIN/11.2/p6880880_112000_Linux-x86-64.zip', :install_files => ['file://$VMORACLEBIN/11.2/p10404530_112030_Linux-x86-64_4of7.zip']}}
EOF5
# this is just a copy of the database databag.
# with the same password, "oraclesecret"
mkdir -p $COOKBOOKDIR/data_bags/oracli
tee $COOKBOOKDIR/data_bags/oracli/foo.json >/dev/null <<EOF6
{
"id":"foo",
"pw":{
"encrypted_data":"DBmrU40EVl9Z15rGIGwSnJ4IxCFieu+B0l7D3HAsdqU=\n",
"iv":"o3ipr3zynuSunRNBdG8RDA==\n",
"version":1,
"cipher":"aes-256-cbc"
}
}
EOF6
kitchen list
kitchen create $COOKBOOK-$OSNODOTS
kitchen converge $COOKBOOK-$OSNODOTS
#License and Authors
#===================
#
#Email:: <[email protected]>
#Author:: Scott Russell
#
#Copyright:: 2013, Scott Russell
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#<http://www.apache.org/licenses/LICENSE-2.0>
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.