This repository has been archived by the owner on Sep 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.pp
95 lines (87 loc) · 2.82 KB
/
install.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
# == Class: nginx::install
#
# This module ensures that Nginx is properly installed, with openresty and Lua.
#
# === Examples
#
# class { 'nginx::install': }
#
# or
#
# include nginx::install
#
# === Authors
#
# Rhommel Lamas <[email protected]>
#
# === Copyright
#
# Copyright 2013 Rhommel Lamas.
class nginx::install (
$provider_id = "${nginx::params::provider_id}",
$openresty_version = "${nginx::params::openresty_version}",
$prefix = "${nginx::params::prefix}",
$openresty_path = "${nginx::params::openresty_path}"
) inherits nginx::params {
File {
owner => 'nginx',
group => 'nginx',
}
# Ensures needed directories exist
if ! defined(File["${prefix}"]) {
file {
"${prefix}":
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0755'
}
}
# Ensure User/group Nginx exists as a system user
group { 'nginx': gid => '1200' }
user {
'nginx':
ensure => 'present',
comment => 'Nginx system user',
uid => '1200',
gid => '1200',
shell => '/bin/false',
groups => 'nginx',
system => true,
}
# Ensure we have the needed Nginx and dependencies packages
file {
"/usr/src/ngx_openresty-${openresty_version}.tar.gz":
ensure => 'present',
source => "puppet:///modules/nginx/packages/ngx_openresty-${openresty_version}.tar.gz",
alias => 'nginx-source-tgz',
before => Exec['untar-nginx-source']
}
# Untar the files.
exec {
"tar xzf ngx_openresty-${openresty_version}.tar.gz":
path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ],
cwd => "${prefix}",
creates => "${prefix}/ngx_openresty-${openresty_version}",
alias => 'untar-nginx-source',
subscribe => File['nginx-source-tgz']
}
# Configure nginx with needed options --with-luajit is required.
exec {
"/bin/ls | ./configure --prefix=${openresty_path} --with-luajit --with-http_iconv_module -j2 && touch ${prefix}/ngx_openresty-${openresty_version}/.config":
path => [ '/bin/', '/sbin/' ,'/usr/bin/','/usr/sbin/' ],
cwd => "${prefix}/ngx_openresty-${openresty_version}",
require => [ Package['libreadline-dev'], Package['libncurses5-dev'], Package['libpcre3'], Package['libpcre3-dev'], Package['libssl-dev'], Package['perl'], Exec['untar-nginx-source'] ],
creates => "${prefix}/ngx_openresty-${openresty_version}/.config",
alias => 'configure-nginx',
before => Exec['make-install']
}
exec {
'make && make install':
path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ],
cwd => "/usr/src/ngx_openresty-${openresty_version}",
alias => 'make-install',
creates => '/opt/openresty/nginx/sbin/nginx',
require => Exec['configure-nginx']
}
}