|
| 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 | +} |
0 commit comments