|
| 1 | +# Class: phpbrew |
| 2 | +# |
| 3 | +# This module manages the installing of phpbrew. |
| 4 | +# |
| 5 | +# Parameters: |
| 6 | +# |
| 7 | +# Actions: |
| 8 | +# |
| 9 | +# Requires: |
| 10 | +# puppetlabs/stdlib |
| 11 | +# Sample Usage: |
| 12 | +# class { 'phpbrew': } |
| 13 | +# |
| 14 | +class phpbrew ( |
| 15 | + $dependencies = undef |
| 16 | +) { |
| 17 | + case $operatingsystem { |
| 18 | + centos, redhat: { |
| 19 | + fail('CentOS or RedHat are not supported yet') |
| 20 | + } |
| 21 | + debian, ubuntu: { |
| 22 | + exec { '/usr/bin/apt-get -y update': } |
| 23 | + |
| 24 | + if ! $dependencies { |
| 25 | + $neededDependencies = [ 'autoconf', 'automake', 'curl', 'build-essential', 'libxslt1-dev', 're2c', 'libxml2-dev', 'php5-cli', 'libmcrypt-dev' ] |
| 26 | + } else { |
| 27 | + $neededDependencies = $dependencies |
| 28 | + } |
| 29 | + |
| 30 | + package { $neededDependencies: |
| 31 | + ensure => 'installed', |
| 32 | + require => Exec['/usr/bin/apt-get -y update'], |
| 33 | + before => Exec['download phpbrew'], |
| 34 | + } |
| 35 | + |
| 36 | + exec { '/usr/bin/apt-get -y build-dep php5': |
| 37 | + require => Exec['/usr/bin/apt-get -y update'], |
| 38 | + before => Exec['download phpbrew'], |
| 39 | + } |
| 40 | + } |
| 41 | + default: { |
| 42 | + fail('Unrecognized operating system for phpbrew') |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + exec { 'download phpbrew': |
| 47 | + command => '/usr/bin/curl -o /tmp/phpbrew https://raw.github.com/c9s/phpbrew/master/phpbrew', |
| 48 | + creates => '/tmp/phpbrew', |
| 49 | + } |
| 50 | + |
| 51 | + file { '/usr/bin/phpbrew': |
| 52 | + source => '/tmp/phpbrew', |
| 53 | + mode => 'a+x', |
| 54 | + require => Exec['download phpbrew'], |
| 55 | + } |
| 56 | + |
| 57 | + exec { 'init phpbrew': |
| 58 | + command => 'sudo /usr/bin/phpbrew init', |
| 59 | + creates => "/root/.phpbrew/bashrc", |
| 60 | + subscribe => File['/usr/bin/phpbrew'], |
| 61 | + refreshonly => true, |
| 62 | + } |
| 63 | + |
| 64 | + file { '/opt/phpbrew': |
| 65 | + ensure => 'directory', |
| 66 | + require => Exec['init phpbrew'], |
| 67 | + } |
| 68 | + |
| 69 | + # Specify where versions of PHP will be installed. |
| 70 | + file { "/root/.phpbrew/init": |
| 71 | + content => 'export PHPBREW_ROOT=/opt/phpbrew', |
| 72 | + require => Exec['init phpbrew'] |
| 73 | + } |
| 74 | + |
| 75 | + # Load phpbrew configuration by default. |
| 76 | + file_line { 'add phpbrew to bashrc': |
| 77 | + path => '/root/.bashrc', |
| 78 | + line => "source /root/.phpbrew/bashrc", |
| 79 | + require => Exec['init phpbrew'], |
| 80 | + } |
| 81 | + |
| 82 | + exec { 'update basbrc': |
| 83 | + command => "bash" |
| 84 | + } |
| 85 | + |
| 86 | + file { "/root/.phpbrew/install_extension.sh": |
| 87 | + ensure => present, |
| 88 | + mode => 'a+x', |
| 89 | + source => "puppet:///modules/phpbrew/install_extension.sh", |
| 90 | + require => Exec['init phpbrew'] |
| 91 | + } |
| 92 | +} |
0 commit comments