Initial version of nginx module
This commit is contained in:
parent
cb8cfa7775
commit
0b4d310656
3 changed files with 127 additions and 0 deletions
106
nginx/manifests/init.pp
Normal file
106
nginx/manifests/init.pp
Normal file
|
@ -0,0 +1,106 @@
|
|||
# Install and configure nginx.
|
||||
#
|
||||
class nginx {
|
||||
|
||||
case $operatingsystem {
|
||||
"openbsd": {
|
||||
$user = "_nginx"
|
||||
$group = "_nginx"
|
||||
}
|
||||
default: {
|
||||
$user = "nginx"
|
||||
$group = "nginx"
|
||||
}
|
||||
}
|
||||
|
||||
package { "nginx":
|
||||
ensure => installed,
|
||||
}
|
||||
|
||||
service { "nginx":
|
||||
enable => true,
|
||||
ensure => running,
|
||||
require => Package["nginx"],
|
||||
}
|
||||
|
||||
file { "/etc/nginx/nginx.conf":
|
||||
ensure => present,
|
||||
mode => 0644,
|
||||
owner => "root",
|
||||
group => $operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
content => template("nginx/nginx.conf.erb"),
|
||||
notify => Service["nginx"],
|
||||
require => Package["nginx"],
|
||||
}
|
||||
|
||||
file { "/etc/nginx/conf.d":
|
||||
ensure => directory,
|
||||
mode => 0644,
|
||||
owner => "root",
|
||||
group => $operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
purge => true,
|
||||
force => true,
|
||||
recurse => true,
|
||||
source => "puppet:///modules/custom/empty",
|
||||
require => Package["nginx"],
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Install and configure nginx with passenger.
|
||||
#
|
||||
class nginx::passenger inherits nginx {
|
||||
|
||||
case $operatingsystem {
|
||||
"openbsd": {
|
||||
Package["nginx"] {
|
||||
flavor => "passenger",
|
||||
}
|
||||
nginx::configfile { "passenger.conf":
|
||||
source => "puppet:///modules/nginx/passenger.conf",
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Not supported on ${operatingsystem}")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Add nginx configuration file.
|
||||
#
|
||||
define nginx::configfile($source="", $content="") {
|
||||
|
||||
file { "/etc/nginx/conf.d/${name}":
|
||||
ensure => present,
|
||||
mode => 0644,
|
||||
owner => "root",
|
||||
group => $operatingsystem ? {
|
||||
"openbsd" => "wheel",
|
||||
default => "root",
|
||||
},
|
||||
notify => Service["nginx"],
|
||||
require => File["/etc/nginx/conf.d"],
|
||||
}
|
||||
|
||||
if $source {
|
||||
File["/etc/nginx/conf.d/${name}"] {
|
||||
source => $source,
|
||||
}
|
||||
}
|
||||
|
||||
if $content {
|
||||
File["/etc/nginx/conf.d/${name}"] {
|
||||
content => $content,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue