forked from gleventhal/SysAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.pp
76 lines (62 loc) · 1.99 KB
/
nginx.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
# Test NginX Puppet Module
# This class installs NginX for Enterprise Linux 6
# Author: Gregg Leventhal 2014
class nginx {
$dl_dir = '/opt/downloads'
$index_url = 'https://github.com/puppetlabs/exercise-webpage.git'
$pull_index_command = "git clone $index_url"
$basic_path = [
'/usr/local/bin', '/bin', '/usr/bin', '/usr/local/sbin', '/usr/sbin', '/sbin', '/usr/local/share'
]
$document_root = '/usr/share/nginx/html/'
$epel = 'epel-release-6-8.noarch'
$epel_rpm = "${epel}.rpm"
$epel_url = "http://dl.fedoraproject.org/pub/epel/6/x86_64/$epel_rpm"
$wget_epel = "wget $epel_url"
$epel_install = "rpm -Uvh $epel_rpm"
file { "$dl_dir":
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0755',
}
exec { "$wget_epel":
path => $basic_path,
unless => "test $(rpm -q ${epel} &>/dev/null)$? -eq 0",
cwd => $dl_dir
}
exec { "$epel_install":
path => $basic_path,
unless => "test $(rpm -q ${epel} &>/dev/null)$? -eq 0",
cwd => $dl_dir
}
package { 'nginx':
ensure => installed
}
package { 'git':
ensure => installed,
before => Exec["$pull_index_command"]
}
exec { "$pull_index_command":
path => $basic_path,
creates => "${document_root}/exercise-webpage",
cwd => $document_root,
}
exec { 'sed -i "s|\(/usr/share/nginx/html/\?\)\(;\)|\1/exercise-webpage\2|" /etc/nginx/conf.d/default.conf':
path => $basic_path,
unless => "grep -q 'exercise-webpage' /etc/nginx/conf.d/default.conf",
require => [
Package['nginx']
]
}
file { '/etc/nginx/conf.d/default.conf':
ensure => present,
require => Package['nginx']
}
service { 'nginx':
ensure => 'running',
subscribe => File['/etc/nginx/conf.d/default.conf']
}
File["$dl_dir"] -> Exec["$wget_epel"] -> Exec["$epel_install"] -> Package['nginx'] -> Exec["$pull_index_command"] -> Service['nginx']
}
include nginx