nginx: Manually merge nginx from parameterize
This commit is contained in:
parent
4b498aa860
commit
efa029b0ba
3 changed files with 73 additions and 95 deletions
|
@ -1,3 +0,0 @@
|
|||
passenger_root /usr/local/lib/phusion_passenger;
|
||||
passenger_ruby /usr/local/bin/ruby18;
|
||||
passenger_log_level 1;
|
|
@ -1,106 +1,89 @@
|
|||
# Install and configure nginx.
|
||||
#
|
||||
class nginx {
|
||||
class nginx(
|
||||
$workers=$::processorcount,
|
||||
) {
|
||||
|
||||
case $::operatingsystem {
|
||||
"openbsd": {
|
||||
$user = "_nginx"
|
||||
$group = "_nginx"
|
||||
}
|
||||
default: {
|
||||
$user = "nginx"
|
||||
$group = "nginx"
|
||||
}
|
||||
case $::operatingsystem {
|
||||
'openbsd': {
|
||||
if $::kernelversion == '5.6' {
|
||||
$user = 'www'
|
||||
$group = 'www'
|
||||
} else {
|
||||
$user = '_nginx'
|
||||
$group = '_nginx'
|
||||
}
|
||||
}
|
||||
|
||||
package { "nginx":
|
||||
ensure => installed,
|
||||
default: {
|
||||
$user = 'nginx'
|
||||
$group = 'nginx'
|
||||
}
|
||||
}
|
||||
|
||||
service { "nginx":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
require => Package["nginx"],
|
||||
if ! ($::operatingsystem == 'OpenBSD' and $::kernelversion == '5.6') {
|
||||
package { 'nginx':
|
||||
ensure => installed,
|
||||
before => File['/etc/nginx/nginx.conf', '/etc/nginx/conf.d'],
|
||||
}
|
||||
}
|
||||
|
||||
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/nginx.conf':
|
||||
ensure => present,
|
||||
mode => '0644',
|
||||
owner => 'root',
|
||||
group => $::operatingsystem ? {
|
||||
'openbsd' => 'wheel',
|
||||
default => 'root',
|
||||
},
|
||||
content => template('nginx/nginx.conf.erb'),
|
||||
notify => Service['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"],
|
||||
}
|
||||
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',
|
||||
notify => Service['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}")
|
||||
}
|
||||
}
|
||||
service { 'nginx':
|
||||
ensure => running,
|
||||
enable => true,
|
||||
start => $::operatingsystem ? {
|
||||
'openbsd' => '/usr/sbin/nginx -u',
|
||||
default => undef,
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# Add nginx configuration file.
|
||||
#
|
||||
define nginx::configfile($source="", $content="") {
|
||||
define nginx::config(
|
||||
$source=undef,
|
||||
$content=undef,
|
||||
) {
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
file { "/etc/nginx/conf.d/${name}":
|
||||
ensure => present,
|
||||
mode => '0644',
|
||||
owner => 'root',
|
||||
group => $::operatingsystem ? {
|
||||
'openbsd' => 'wheel',
|
||||
default => 'root',
|
||||
},
|
||||
content => $content,
|
||||
source => $source,
|
||||
notify => Service['nginx'],
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
user <%= @user %>;
|
||||
worker_processes <%= @processorcount %>;
|
||||
worker_processes <%= @workers %>;
|
||||
worker_rlimit_nofile 1024;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
|
@ -9,10 +10,7 @@ http {
|
|||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
sendfile on;
|
||||
tcp_nodelay on;
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 65;
|
||||
server_tokens off;
|
||||
|
||||
include conf.d/*.conf;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue