-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinit.pp
executable file
·201 lines (183 loc) · 5.23 KB
/
init.pp
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
195
196
197
198
199
200
201
# Class: phpbrew
#
# This module manages the installing of phpbrew.
#
# Parameters:
#
# Actions:
#
# Requires:
# puppetlabs/stdlib
# Sample Usage:
# class { 'phpbrew': }
#
class phpbrew (
String $php_install_dir = '/opt/phpbrew',
Boolean $system_wide = false,
Array $additional_dependencies = []
) {
<<<<<<< Updated upstream
case $::operatingsystem {
centos: {
if $::operatingsystemmajrelease == '7' {
$dependencies = [
'curl',
'libxslt-devel',
're2c',
'libxml2-devel',
'php-cli',
'libmcrypt-devel',
'php-devel',
'openssl-devel',
'bzip2-devel',
'libicu-devel',
'readline-devel'
] + $additional_dependencies
=======
case $::operatingsystem {
centos: {
$dependencies = [
'curl',
'libxslt-devel',
're2c',
'libxml2-devel',
'php-cli',
'libmcrypt-devel',
'php-devel',
'openssl-devel',
'bzip2-devel',
'libicu-devel',
'readline-devel'
]
if Integer( $::operatingsystemmajrelease ) >= 8 {
$installDevToolsCommand = '/usr/bin/dnf -y group install "Development Tools"'
} elsif $::operatingsystemmajrelease == '7' {
$installDevToolsCommand = '/usr/bin/yum -y groupinstall "Development Tools"'
} else {
fail("CentOS support only tested on major version 7 and 8, you are running version '${::operatingsystemmajrelease}'")
}
exec { 'Installing Development Tools package group':
command => $installDevToolsCommand,
timeout => 3600,
tries => 3,
}
>>>>>>> Stashed changes
exec { 'Installing Development Tools package group':
command => '/usr/bin/yum -y groupinstall Development Tools'
}
each($dependencies) |$dependency| {
if ! defined(Package[$dependency]) {
package { $dependency:
ensure => 'installed',
before => Exec['download phpbrew'],
}
}
}
} else {
fail("CentOS support only tested on major version 7, you are running version '${::operatingsystemmajrelease}'")
}
}
debian, ubuntu: {
exec { '/usr/bin/apt-get -y update': }
$dependencies = [
'autoconf',
'automake',
'curl',
'build-essential',
'libxslt1-dev',
're2c',
'libxml2-dev',
'php5-cli',
'libmcrypt-dev',
'php5-dev'
]
each($dependencies) |$dependency| {
if ! defined(Package[$dependency]) {
package { $dependency:
ensure => 'installed',
require => Exec['/usr/bin/apt-get -y update'],
before => Exec['download phpbrew'],
}
}
}
exec { '/usr/bin/apt-get -y build-dep php5':
require => Exec['/usr/bin/apt-get -y update'],
before => Exec['download phpbrew'],
}
}
redhat: {
fail('RedHat is not supported yet')
}
default: {
fail('Unrecognized operating system for phpbrew')
}
}
exec { 'download phpbrew':
command => '/usr/bin/wget -P /tmp https://raw.github.com/c9s/phpbrew/master/phpbrew',
creates => '/tmp/phpbrew',
}
file { '/usr/bin/phpbrew':
source => '/tmp/phpbrew',
mode => 'a+x',
require => Exec['download phpbrew'],
}
exec { 'init phpbrew':
command => '/usr/bin/sudo /usr/bin/phpbrew init',
creates => '/root/.phpbrew/bashrc',
subscribe => File['/usr/bin/phpbrew'],
refreshonly => true,
}
file { $php_install_dir:
ensure => 'directory',
require => Exec['init phpbrew'],
}
file { '/usr/lib/cgi-bin':
ensure => 'directory',
require => Exec['init phpbrew'],
}
# Specify where versions of PHP will be installed.
file { '/root/.phpbrew/init':
content => "export PHPBREW_ROOT=${php_install_dir}",
require => Exec['init phpbrew']
}
# Load phpbrew configuration by default.
if $system_wide {
###################################################################
# Init as vagrant user to use when need to switch php
# and use it from vagrant console for example for composer command
###################################################################
exec { 'init phpbrew as vagrant':
command => '/usr/bin/phpbrew init',
creates => '/home/vagrant/.phpbrew/bashrc',
subscribe => File['/usr/bin/phpbrew'],
refreshonly => true,
user => "vagrant",
environment => ["HOME=/home/vagrant"],
}
file { '/opt/phpbrew/bashrc':
ensure => present,
content => template('phpbrew/bashrc.erb'),
require => Exec['init phpbrew']
}
file { "/etc/profile.d/phpbrew.sh":
ensure => present,
content => template('phpbrew/phpbrew.sh.erb'),
require => Exec['init phpbrew']
}
} else {
file_line { 'add phpbrew to bashrc':
path => '/root/.bashrc',
line => 'source /root/.phpbrew/bashrc',
require => Exec['init phpbrew'],
}
}
exec { 'update basbrc':
command => '/bin/bash'
}
file { '/root/.phpbrew/install_extension.sh':
ensure => present,
mode => 'a+x',
source => 'puppet:///modules/phpbrew/install_extension.sh',
require => Exec['init phpbrew']
}
}