Skip to content

Commit a107d0e

Browse files
committed
added oracle-xe installation puppet scripts and install oci8
1 parent afce9a4 commit a107d0e

File tree

11 files changed

+278
-10
lines changed

11 files changed

+278
-10
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/vendor
2-
/.vagrant
2+
/.vagrant*

puppet/manifests/base.pp

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node homestead {
2+
include oracle::server
3+
include oracle::swap
4+
include oracle::xe
5+
6+
user { "vagrant":
7+
groups => "dba",
8+
# So that we let Oracle installer create the group
9+
require => Service["oracle-xe"],
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Oracle 11g XE kernel parameters
2+
fs.file-max=6815744
3+
net.ipv4.ip_local_port_range=9000 65000
4+
kernel.sem=250 32000 100 128
5+
kernel.shmmax=107374183
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
case "$1" in
4+
start)
5+
mkdir /var/lock/subsys 2>/dev/null
6+
touch /var/lock/subsys/listener
7+
rm -rf /dev/shm 2>/dev/null
8+
mkdir /dev/shm 2>/dev/null
9+
mount -t tmpfs shmfs -o size=2048m /dev/shm
10+
;;
11+
*)
12+
echo error
13+
exit 1
14+
;;
15+
esac

puppet/modules/oracle/files/chkconfig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! /bin/bash
2+
# Oracle 11gR2 XE installer chkconfig hack for Ubuntu
3+
# http://meandmyubuntulinux.blogspot.co.uk/2012/05/installing-oracle-11g-r2-express.html
4+
5+
file=/etc/init.d/oracle-xe
6+
7+
if [[ ! `tail -n1 $file | grep INIT` ]]; then
8+
echo >> $file
9+
echo '### BEGIN INIT INFO' >> $file
10+
echo '# Provides: OracleXE' >> $file
11+
echo '# Required-Start: $remote_fs $syslog' >> $file
12+
echo '# Required-Stop: $remote_fs $syslog' >> $file
13+
echo '# Default-Start: 2 3 4 5' >> $file
14+
echo '# Default-Stop: 0 1 6' >> $file
15+
echo '# Short-Description: Oracle 11g Express Edition' >> $file
16+
echo '### END INIT INFO' >> $file
17+
fi
18+
19+
update-rc.d oracle-xe defaults 80 01
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
2+
export ORACLE_SID=XE
3+
export NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh`
4+
export ORACLE_BASE=/u01/app/oracle
5+
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
6+
export PATH=$ORACLE_HOME/bin:$PATH

puppet/modules/oracle/files/xe.rsp

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ORACLE_LISTENER_PORT=1521
2+
ORACLE_HTTP_PORT=0
3+
ORACLE_PASSWORD=secret
4+
ORACLE_CONFIRM_PASSWORD=secret
5+
ORACLE_DBENABLE=y
+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
class oracle::server {
2+
exec { "apt-update":
3+
command => "/usr/bin/apt-get -y update",
4+
timeout => 3600;
5+
}
6+
7+
package {
8+
["puppet-common", "alien", "bc", "libaio1", "unixodbc", "unzip", "rlwrap", "dos2unix"]:
9+
ensure => installed;
10+
}
11+
12+
exec { "procps":
13+
refreshonly => true,
14+
command => "/etc/init.d/procps restart";
15+
}
16+
17+
file {
18+
"/tmp/chkconfig":
19+
mode => 0755,
20+
source => "puppet:///modules/oracle/chkconfig";
21+
"/tmp/60-oracle.conf":
22+
notify => Exec['procps'],
23+
source => "puppet:///modules/oracle/60-oracle.conf";
24+
"/tmp/S01shm_load":
25+
mode => 0755,
26+
source => "puppet:///modules/oracle/S01shm_load";
27+
}
28+
29+
# If we're running on Windows, then Git may have converted line endings to CRLF upon cloning the
30+
# repository. Here we use dos2unix to make sure that they are LF.
31+
exec {
32+
"dos2unix chkconfig":
33+
command => "/usr/bin/dos2unix -n /tmp/chkconfig /sbin/chkconfig",
34+
creates => "/sbin/chkconfig",
35+
require => [File["/tmp/chkconfig"], Package["dos2unix"]];
36+
"dos2unix 60-oracle.conf":
37+
command => "/usr/bin/dos2unix -n /tmp/60-oracle.conf /etc/sysctl.d/60-oracle.conf",
38+
creates => "/etc/sysctl.d/60-oracle.conf",
39+
require => [File["/tmp/60-oracle.conf"], Package["dos2unix"]];
40+
"dos2unix S01shm_load":
41+
command => "/usr/bin/dos2unix -n /tmp/S01shm_load /etc/rc2.d/S01shm_load",
42+
creates => "/etc/rc2.d/S01shm_load",
43+
require => [File["/tmp/S01shm_load"], Package["dos2unix"]];
44+
}
45+
46+
user {
47+
"syslog":
48+
ensure => present,
49+
groups => ["syslog", "adm"];
50+
}
51+
52+
group {
53+
"puppet":
54+
ensure => present;
55+
}
56+
57+
exec { "set up shm":
58+
command => "/etc/rc2.d/S01shm_load start",
59+
require => Exec["dos2unix S01shm_load"],
60+
user => root,
61+
unless => "/bin/mount | grep /dev/shm 2>/dev/null";
62+
}
63+
64+
Exec["apt-update"] -> Package <| |>
65+
}
66+
67+
class oracle::swap {
68+
exec {
69+
"create swapfile":
70+
# Needs to be 2 times the memory
71+
command => "/bin/dd if=/dev/zero of=/swapfile bs=1M count=1024",
72+
user => root,
73+
creates => "/swapfile";
74+
"set up swapfile":
75+
command => "/sbin/mkswap /swapfile",
76+
require => Exec["create swapfile"],
77+
user => root,
78+
unless => "/usr/bin/file /swapfile | grep 'swap file' 2>/dev/null";
79+
"enable swapfile":
80+
command => "/sbin/swapon /swapfile",
81+
require => Exec["set up swapfile"],
82+
user => root,
83+
unless => "/bin/cat /proc/swaps | grep '^/swapfile' 2>/dev/null";
84+
"add swapfile entry to fstab":
85+
command => "/bin/echo >>/etc/fstab /swapfile swap swap defaults 0 0",
86+
user => root,
87+
unless => "/bin/grep '^/swapfile' /etc/fstab 2>/dev/null";
88+
}
89+
90+
file {
91+
"/swapfile":
92+
mode => 600,
93+
owner => root,
94+
group => root,
95+
require => Exec['create swapfile'];
96+
}
97+
}
98+
99+
class oracle::xe {
100+
file {
101+
"/home/vagrant/oracle-xe-11.2.0-1.0.x86_64.rpm.zip":
102+
source => "puppet:///modules/oracle/oracle-xe-11.2.0-1.0.x86_64.rpm.zip";
103+
"/tmp/oracle-env.sh":
104+
source => "puppet:///modules/oracle/oracle-env.sh";
105+
"/tmp/xe.rsp.orig":
106+
source => "puppet:///modules/oracle/xe.rsp";
107+
"/bin/awk":
108+
ensure => link,
109+
target => "/usr/bin/awk";
110+
"/var/lock/subsys":
111+
ensure => directory;
112+
"/var/lock/subsys/listener":
113+
ensure => present;
114+
}
115+
116+
exec {
117+
"dos2unix oracle-env.sh":
118+
command => "/usr/bin/dos2unix -n /tmp/oracle-env.sh /etc/profile.d/oracle-env.sh",
119+
creates => "/etc/profile.d/oracle-env.sh",
120+
require => [File["/tmp/oracle-env.sh"], Package["dos2unix"]];
121+
"dos2unix xe.rsp":
122+
command => "/usr/bin/dos2unix -n /tmp/xe.rsp.orig /tmp/xe.rsp",
123+
creates => "/tmp/xe.rsp",
124+
require => [File["/tmp/xe.rsp.orig"], Package["dos2unix"]];
125+
}
126+
127+
exec {
128+
"unzip xe":
129+
command => "/usr/bin/unzip -o oracle-xe-11.2.0-1.0.x86_64.rpm.zip",
130+
require => [Package["unzip"], File["/home/vagrant/oracle-xe-11.2.0-1.0.x86_64.rpm.zip"]],
131+
cwd => "/home/vagrant",
132+
user => root,
133+
creates => "/home/vagrant/oracle-xe-11.2.0-1.0.x86_64.rpm",
134+
timeout => 3600,
135+
unless => "/usr/bin/test -f /etc/default/oracle-xe";
136+
"alien xe":
137+
command => "/usr/bin/alien --to-deb --scripts Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm",
138+
cwd => "/home/vagrant",
139+
require => [Package["alien"], Exec["unzip xe"]],
140+
creates => "/home/vagrant/oracle-xe_11.2.0-2_amd64.deb",
141+
user => root,
142+
timeout => 3600,
143+
unless => "/usr/bin/test -f /etc/default/oracle-xe";
144+
"configure xe":
145+
command => "/etc/init.d/oracle-xe configure responseFile=/tmp/xe.rsp >> /tmp/xe-install.log",
146+
timeout => 3600,
147+
require => [Package["oracle-xe"],
148+
Exec["dos2unix oracle-env.sh"],
149+
Exec["dos2unix xe.rsp"],
150+
File["/var/lock/subsys/listener"],
151+
Exec["set up shm"],
152+
Exec["enable swapfile"]],
153+
creates => "/etc/default/oracle-xe";
154+
}
155+
156+
package {
157+
"oracle-xe":
158+
provider => "dpkg",
159+
ensure => latest,
160+
require => [Exec["alien xe"]],
161+
source => "/home/vagrant/oracle-xe_11.2.0-2_amd64.deb",
162+
}
163+
164+
exec {
165+
"run chkconfig":
166+
command => "/sbin/chkconfig",
167+
user => root,
168+
require => Service["oracle-xe"];
169+
}
170+
171+
service {
172+
"oracle-xe":
173+
ensure => "running",
174+
require => [Package["oracle-xe"],
175+
Exec["configure xe"],
176+
Exec["dos2unix chkconfig"],
177+
Exec["dos2unix 60-oracle.conf"]],
178+
}
179+
}

scripts/create-oracle.sh

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
DB=$1
44

5-
LogDirectory='/home/vagrant/oracle'
6-
DataDirectory='/home/vagrant/oracle/data'
7-
8-
/u01/app/oracle/product/11.2.0/xe/bin/sqlplus -s <<EOF > ${LogDirectory}/query.log
9-
system/secret
5+
/u01/app/oracle/product/11.2.0/xe/bin/sqlplus -s <<EOF
6+
sys/secret as sysdba
107
set linesize 32767
118
set feedback off
129
set heading off

scripts/homestead.rb

+26-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ def Homestead.configure(config, settings)
44
ENV['VAGRANT_DEFAULT_PROVIDER'] = settings["provider"] ||= "virtualbox"
55

66
# Configure The Box
7-
config.vm.box = "yajra/homestead-oracle"
7+
config.vm.box = "laravel/homestead"
88
config.vm.hostname = "homestead"
99

1010
# Configure A Private Network IP
1111
config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10"
1212

1313
# Configure A Few VirtualBox Settings
1414
config.vm.provider "virtualbox" do |vb|
15-
vb.name = 'homestead-oracle'
15+
vb.name = 'vm-oracle'
1616
vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"]
1717
vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"]
1818
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
@@ -21,17 +21,39 @@ def Homestead.configure(config, settings)
2121
end
2222

2323
config.vm.provider "vmware_fusion" do |v|
24-
v.name = 'homestead-oracle'
24+
v.name = 'vm-oracle'
2525
v.memory = settings["memory"] ||= "2048"
2626
v.cpus = settings["cpus"] ||= "1"
2727
end
2828

29+
# enable/disable vbguest update
30+
config.vbguest.auto_update = false
31+
32+
# set date/time
33+
config.vm.provision :shell, :inline => "echo \"America/New_York\" | sudo tee /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata"
34+
35+
# install puppet for oracle installation
36+
config.vm.provision :shell, :inline => "apt-get -y install puppet"
37+
38+
# configure oracle
39+
config.vm.provision :puppet do |puppet|
40+
puppet.manifests_path = 'puppet/manifests'
41+
puppet.manifest_file = 'base.pp'
42+
puppet.module_path = 'puppet/modules'
43+
puppet.options = '--verbose --trac'
44+
end
45+
46+
# install oci8.so extension
47+
config.vm.provision "shell" do |s|
48+
s.path = "./scripts/install-oci8.sh"
49+
end
50+
2951
# Configure Port Forwarding To The Box
3052
config.vm.network "forwarded_port", guest: 80, host: 8000
3153
config.vm.network "forwarded_port", guest: 443, host: 44300
3254
config.vm.network "forwarded_port", guest: 3306, host: 33060
3355
config.vm.network "forwarded_port", guest: 5432, host: 54320
34-
config.vm.network "forwarded_port", guest: 1521, host: 1521
56+
config.vm.network "forwarded_port", guest: 1521, host: 15210
3557

3658
# Add Custom Ports From Configuration
3759
if settings.has_key?("ports")

scripts/install-oci8.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
if php -m | grep oci8; then
2+
echo 'oracle extension already installed!'
3+
else
4+
echo autodetect | pecl install oci8
5+
echo 'extension=oci8.so' >> /etc/php5/fpm/php.ini
6+
echo 'extension=oci8.so' >> /etc/php5/cli/php.ini
7+
echo "env[ORACLE_HOME] = '/u01/app/oracle/product/11.2.0/xe'" > /etc/php5/fpm/php5-fpm.conf
8+
echo "env[LD_LIBRARY_PATH] = '/u01/app/oracle/product/11.2.0/xe/lib'" >> /etc/php5/fpm/php5-fpm.conf
9+
fi

0 commit comments

Comments
 (0)