commit
9c9b5c2c78
11 changed files with 297 additions and 349 deletions
11
Modulefile
11
Modulefile
|
@ -1,9 +1,8 @@
|
|||
name 'jfryman-nginx'
|
||||
name 'puppetlabs-nginx'
|
||||
version '0.0.1'
|
||||
source 'http://github.com/jfryman/puppet-nginx'
|
||||
author 'James Fryman'
|
||||
license 'Apache 2'
|
||||
source 'http://github.com/puppetlabs/puppetlabs-nginx'
|
||||
author 'puppetlabs'
|
||||
license 'Apache License Version 2.0'
|
||||
summary 'Puppet NGINX management module'
|
||||
description 'This module can be used for basic NGINX Management'
|
||||
project_page 'http://github.com/jfryman/puppet-nginx'
|
||||
|
||||
project_page 'http://github.com/puppetlabs/puppetlabs-nginx'
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# This module manages NGINX bootstrap and configuration
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -13,52 +13,52 @@
|
|||
# Sample Usage:
|
||||
#
|
||||
# This class file is not called directly
|
||||
class nginx::config inherits nginx::params {
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}/conf.d":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${nginx::config::nx_run_dir}":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${nginx::config::nx_client_body_temp_path}":
|
||||
ensure => directory,
|
||||
owner => $nginx::params::nx_daemon_user,
|
||||
}
|
||||
|
||||
file {"${nginx::config::nx_proxy_temp_path}":
|
||||
ensure => directory,
|
||||
owner => $nginx::params::nx_daemon_user,
|
||||
}
|
||||
|
||||
file { '/etc/nginx/sites-enabled/default':
|
||||
ensure => absent,
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}/nginx.conf":
|
||||
ensure => file,
|
||||
content => template('nginx/conf.d/nginx.conf.erb'),
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}/conf.d/proxy.conf":
|
||||
ensure => file,
|
||||
content => template('nginx/conf.d/proxy.conf.erb'),
|
||||
}
|
||||
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d":
|
||||
ensure => directory,
|
||||
purge => true,
|
||||
recurse => true,
|
||||
}
|
||||
}
|
||||
class nginx::config inherits nginx::params {
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}/conf.d":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${nginx::config::nx_run_dir}":
|
||||
ensure => directory,
|
||||
}
|
||||
|
||||
file { "${nginx::config::nx_client_body_temp_path}":
|
||||
ensure => directory,
|
||||
owner => $nginx::params::nx_daemon_user,
|
||||
}
|
||||
|
||||
file {"${nginx::config::nx_proxy_temp_path}":
|
||||
ensure => directory,
|
||||
owner => $nginx::params::nx_daemon_user,
|
||||
}
|
||||
|
||||
file { '/etc/nginx/sites-enabled/default':
|
||||
ensure => absent,
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}/nginx.conf":
|
||||
ensure => file,
|
||||
content => template('nginx/conf.d/nginx.conf.erb'),
|
||||
}
|
||||
|
||||
file { "${nginx::params::nx_conf_dir}/conf.d/proxy.conf":
|
||||
ensure => file,
|
||||
content => template('nginx/conf.d/proxy.conf.erb'),
|
||||
}
|
||||
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d":
|
||||
ensure => directory,
|
||||
purge => true,
|
||||
recurse => true,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# This module manages NGINX package installation
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -16,13 +16,13 @@
|
|||
class nginx::package {
|
||||
case $operatingsystem {
|
||||
centos,fedora,rhel: {
|
||||
include nginx::package::redhat
|
||||
include nginx::package::redhat
|
||||
}
|
||||
debian,ubuntu: {
|
||||
include nginx::package::debian
|
||||
include nginx::package::debian
|
||||
}
|
||||
opensuse,suse: {
|
||||
include nginx::package::suse
|
||||
include nginx::package::suse
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# This module manages NGINX package installation on debian based systems
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -14,7 +14,7 @@
|
|||
#
|
||||
# This class file is not called directly
|
||||
class nginx::package::debian {
|
||||
package { 'nginx':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
package { 'nginx':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# This module manages NGINX package installation on RedHat based systems
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -14,19 +14,8 @@
|
|||
#
|
||||
# This class file is not called directly
|
||||
class nginx::package::redhat {
|
||||
package { 'nginx':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'GeoIP':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'gd':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'libXpm':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'libxslt':
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
$redhat_packages = ['nginx', 'GeoIP', 'gd', 'libXpm', 'libxslt']
|
||||
package { $redhat_packages:
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,71 +3,27 @@
|
|||
# This module manages NGINX package installation for SuSE based systems
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
# This module contains all of the required package for SuSE. Apache and all
|
||||
# other packages listed below are built into the packaged RPM spec for
|
||||
# SuSE and OpenSuSE.
|
||||
# other packages listed below are built into the packaged RPM spec for
|
||||
# SuSE and OpenSuSE.
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
#
|
||||
# This class file is not called directly
|
||||
class nginx::package::suse {
|
||||
package { 'nginx-0.8':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'apache2':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'apache2-itk':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'apache2-utils':
|
||||
ensure => present,
|
||||
}
|
||||
package { 'gd':
|
||||
ensure => present,
|
||||
}
|
||||
package { "libapr1":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "libapr-util1":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "libjpeg62":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "libpng14-14":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "libxslt":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-daemon_controller":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-fastthread":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-file-tail":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-passenger":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-passenger-nginx":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-rack":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-rake":
|
||||
ensure => installed,
|
||||
}
|
||||
package { "rubygem-spruz":
|
||||
ensure => installed,
|
||||
}
|
||||
$suse_packages = [
|
||||
'nginx-0.8', 'apache2', 'apache2-itk', 'apache2-utils', 'gd', 'libapr1',
|
||||
'libapr-util1', 'libjpeg62', 'libpng14-14', 'libxslt', 'rubygem-daemon_controller',
|
||||
'rubygem-fastthread', 'rubygem-file-tail', 'rubygem-passenger',
|
||||
'rubygem-passenger-nginx', 'rubygem-rack', 'rubygem-rake', 'rubygem-spruz',
|
||||
]
|
||||
|
||||
package { $suse_packages:
|
||||
ensure => present,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# This module manages NGINX paramaters
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -14,39 +14,43 @@
|
|||
#
|
||||
# This class file is not called directly
|
||||
class nginx::params {
|
||||
$nx_temp_dir = '/tmp'
|
||||
$nx_run_dir = '/var/nginx'
|
||||
$nx_temp_dir = '/tmp'
|
||||
$nx_run_dir = '/var/nginx'
|
||||
|
||||
$nx_conf_dir = '/etc/nginx'
|
||||
$nx_worker_processes = 1
|
||||
$nx_worker_connections = 1024
|
||||
$nx_multi_accept = off
|
||||
$nx_sendfile = on
|
||||
$nx_keepalive_timeout = 65
|
||||
$nx_tcp_nodelay = on
|
||||
$nx_gzip = on
|
||||
|
||||
$nx_proxy_redirect = off
|
||||
$nx_proxy_set_header = ['Host $host', 'X-Real-IP $remote_addr', 'X-Forwarded-For $proxy_add_x_forwarded_for']
|
||||
$nx_client_body_temp_path = "${nx_run_dir}/client_body_temp"
|
||||
$nx_client_body_buffer_size = '128k'
|
||||
$nx_client_max_body_size = '10m'
|
||||
$nx_proxy_temp_path = "${nx_run_dir}/proxy_temp"
|
||||
$nx_proxy_connect_timeout = '90'
|
||||
$nx_proxy_send_timeout = '90'
|
||||
$nx_proxy_read_timeout = '90'
|
||||
$nx_proxy_buffers = '32 4k'
|
||||
|
||||
$nx_logdir = $kernel ? {
|
||||
/(?i-mx:linux)/ => '/var/log/nginx',
|
||||
}
|
||||
|
||||
$nx_pid = $kernel ? {
|
||||
/(?i-mx:linux)/ => '/var/run/nginx.pid',
|
||||
}
|
||||
|
||||
$nx_daemon_user = $operatingsystem ? {
|
||||
/(?i-mx:debian|ubuntu)/ => 'www-data',
|
||||
/(?i-mx:fedora|rhel|centos|suse|opensuse)/ => 'nginx',
|
||||
}
|
||||
}
|
||||
$nx_conf_dir = '/etc/nginx'
|
||||
$nx_worker_processes = 1
|
||||
$nx_worker_connections = 1024
|
||||
$nx_multi_accept = off
|
||||
$nx_sendfile = on
|
||||
$nx_keepalive_timeout = 65
|
||||
$nx_tcp_nodelay = on
|
||||
$nx_gzip = on
|
||||
|
||||
$nx_proxy_redirect = off
|
||||
$nx_proxy_set_header = [
|
||||
'Host $host', 'X-Real-IP $remote_addr',
|
||||
'X-Forwarded-For $proxy_add_x_forwarded_for',
|
||||
]
|
||||
|
||||
$nx_client_body_temp_path = "${nx_run_dir}/client_body_temp"
|
||||
$nx_client_body_buffer_size = '128k'
|
||||
$nx_client_max_body_size = '10m'
|
||||
$nx_proxy_temp_path = "${nx_run_dir}/proxy_temp"
|
||||
$nx_proxy_connect_timeout = '90'
|
||||
$nx_proxy_send_timeout = '90'
|
||||
$nx_proxy_read_timeout = '90'
|
||||
$nx_proxy_buffers = '32 4k'
|
||||
|
||||
$nx_logdir = $kernel ? {
|
||||
/(?i-mx:linux)/ => '/var/log/nginx',
|
||||
}
|
||||
|
||||
$nx_pid = $kernel ? {
|
||||
/(?i-mx:linux)/ => '/var/run/nginx.pid',
|
||||
}
|
||||
|
||||
$nx_daemon_user = $operatingsystem ? {
|
||||
/(?i-mx:debian|ubuntu)/ => 'www-data',
|
||||
/(?i-mx:fedora|rhel|centos|suse|opensuse)/ => 'nginx',
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,59 +24,58 @@
|
|||
# location => '/bob',
|
||||
# vhost => 'test2.local',
|
||||
# }
|
||||
define nginx::resource::location(
|
||||
$ensure = 'present',
|
||||
$vhost = undef,
|
||||
$location,
|
||||
$www_root = undef,
|
||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||
$proxy = undef,
|
||||
$ssl = 'false',
|
||||
$option = undef
|
||||
){
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
## Shared Variables
|
||||
$ensure_real = $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
}
|
||||
|
||||
# Use proxy template if $proxy is defined, otherwise use directory template.
|
||||
if ($proxy != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_proxy.erb')
|
||||
} else {
|
||||
$content_real = template('nginx/vhost/vhost_location_directory.erb')
|
||||
}
|
||||
|
||||
## Check for various error condtiions
|
||||
if ($vhost == undef) {
|
||||
fail('Cannot create a location reference without attaching to a virtual host')
|
||||
}
|
||||
if (($www_root == undef) and ($proxy == undef)) {
|
||||
fail('Cannot create a location reference without a www_root or proxy defined')
|
||||
}
|
||||
if (($www_root != undef) and ($proxy != undef)) {
|
||||
fail('Cannot define both directory and proxy in a virtual host')
|
||||
}
|
||||
|
||||
|
||||
## Create stubs for vHost File Fragment Pattern
|
||||
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-500-${name}":
|
||||
ensure => $ensure_real,
|
||||
content => $content_real,
|
||||
}
|
||||
|
||||
## Only create SSL Specific locations if $ssl is true.
|
||||
if ($ssl == 'true') {
|
||||
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl":
|
||||
ensure => $ensure_real,
|
||||
content => $content_re,
|
||||
}
|
||||
define nginx::resource::location(
|
||||
$ensure = present,
|
||||
$vhost = undef,
|
||||
$www_root = undef,
|
||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||
$proxy = undef,
|
||||
$ssl = false,
|
||||
$option = undef,
|
||||
$location
|
||||
) {
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
## Shared Variables
|
||||
$ensure_real = $ensure ? {
|
||||
'absent' => absent,
|
||||
default => file,
|
||||
}
|
||||
|
||||
# Use proxy template if $proxy is defined, otherwise use directory template.
|
||||
if ($proxy != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_proxy.erb')
|
||||
} else {
|
||||
$content_real = template('nginx/vhost/vhost_location_directory.erb')
|
||||
}
|
||||
|
||||
## Check for various error condtiions
|
||||
if ($vhost == undef) {
|
||||
fail('Cannot create a location reference without attaching to a virtual host')
|
||||
}
|
||||
if (($www_root == undef) and ($proxy == undef)) {
|
||||
fail('Cannot create a location reference without a www_root or proxy defined')
|
||||
}
|
||||
if (($www_root != undef) and ($proxy != undef)) {
|
||||
fail('Cannot define both directory and proxy in a virtual host')
|
||||
}
|
||||
|
||||
## Create stubs for vHost File Fragment Pattern
|
||||
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-500-${name}":
|
||||
ensure => $ensure_real,
|
||||
content => $content_real,
|
||||
}
|
||||
|
||||
## Only create SSL Specific locations if $ssl is true.
|
||||
if ($ssl == 'true') {
|
||||
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl":
|
||||
ensure => $ensure_real,
|
||||
content => $content_real,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,26 +14,27 @@
|
|||
# nginx::resource::upstream { 'proxypass':
|
||||
# ensure => present,
|
||||
# members => [
|
||||
# 'localhost:3000',
|
||||
# 'localhost:3001',
|
||||
# 'localhost:3002',
|
||||
# 'localhost:3000',
|
||||
# 'localhost:3001',
|
||||
# 'localhost:3002',
|
||||
# ],
|
||||
# }
|
||||
define nginx::resource::upstream (
|
||||
$ensure = 'present',
|
||||
$members
|
||||
){
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
file { "/etc/nginx/conf.d/${name}-upstream.conf":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/conf.d/upstream.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
}
|
||||
$ensure = 'present',
|
||||
$members
|
||||
) {
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
file { "/etc/nginx/conf.d/${name}-upstream.conf":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/conf.d/upstream.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# [*ensure*] - Enables or disables the specified location (present|absent)
|
||||
# [*listen_ip*] - Default IP Address for NGINX to listen with this vHost on. Defaults to all interfaces (*)
|
||||
# [*listen_port*] - Default IP Port for NGINX to listen with this vHost on. Defaults to TCP 80
|
||||
# [*ipv6_enable*] - BOOL value to enable/disable IPv6 support (false|true). Module will check to see if IPv6
|
||||
# [*ipv6_enable*] - BOOL value to enable/disable IPv6 support (false|true). Module will check to see if IPv6
|
||||
# support exists on your system before enabling.
|
||||
# [*ipv6_listen_ip*] - Default IPv6 Address for NGINX to listen with this vHost on. Defaults to all interfaces (::)
|
||||
# [*ipv6_listen_port*] - Default IPv6 Port for NGINX to listen with this vHost on. Defaults to TCP 80
|
||||
|
@ -15,7 +15,7 @@
|
|||
# with nginx::resource::upstream
|
||||
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
|
||||
# [*ssl_cert*] - Pre-generated SSL Certificate file to reference for SSL Support. This is not generated by this module.
|
||||
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module.
|
||||
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module.
|
||||
# [*www_root*] - Specifies the location on disk for files to be read from. Cannot be set in conjunction with $proxy
|
||||
#
|
||||
# Actions:
|
||||
|
@ -31,88 +31,88 @@
|
|||
# ssl_key => '/tmp/server.pem',
|
||||
# }
|
||||
define nginx::resource::vhost(
|
||||
$ensure = 'enable',
|
||||
$listen_ip = '*',
|
||||
$listen_port = '80',
|
||||
$ipv6_enable = 'false',
|
||||
$ipv6_listen_ip = '::',
|
||||
$ipv6_listen_port = '80',
|
||||
$ssl = 'false',
|
||||
$ssl_cert = undef,
|
||||
$ssl_key = undef,
|
||||
$proxy = undef,
|
||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||
$www_root = undef
|
||||
$ensure = 'enable',
|
||||
$listen_ip = '*',
|
||||
$listen_port = '80',
|
||||
$ipv6_enable = false,
|
||||
$ipv6_listen_ip = '::',
|
||||
$ipv6_listen_port = '80',
|
||||
$ssl = false,
|
||||
$ssl_cert = undef,
|
||||
$ssl_key = undef,
|
||||
$proxy = undef,
|
||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||
$www_root = undef
|
||||
) {
|
||||
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
|
||||
# and support does not exist for it in the kernel.
|
||||
if ($ipv6_enable == 'true') and ($ipaddress6) {
|
||||
warning('nginx: IPv6 support is not enabled or configured properly')
|
||||
}
|
||||
|
||||
# Check to see if SSL Certificates are properly defined.
|
||||
if ($ssl == 'true') {
|
||||
if ($ssl_cert == undef) or ($ssl_key == undef) {
|
||||
fail('nginx: SSL certificate/key (ssl_cert/ssl_cert) and/or SSL Private must be defined and exist on the target system(s)')
|
||||
}
|
||||
}
|
||||
|
||||
# Use the File Fragment Pattern to construct the configuration files.
|
||||
# Create the base configuration file reference.
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-001":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_header.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
# Create the default location reference for the vHost
|
||||
nginx::resource::location {"${name}-default":
|
||||
ensure => $ensure,
|
||||
vhost => $name,
|
||||
ssl => $ssl,
|
||||
location => '/',
|
||||
proxy => $proxy,
|
||||
www_root => $www_root,
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
# Create a proper file close stub.
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-699":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_footer.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
# Create SSL File Stubs if SSL is enabled
|
||||
if ($ssl == 'true') {
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-700-ssl":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_ssl_header.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-999-ssl":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_footer.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File {
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
}
|
||||
|
||||
# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
|
||||
# and support does not exist for it in the kernel.
|
||||
if ($ipv6_enable == 'true') and ($ipaddress6) {
|
||||
warning('nginx: IPv6 support is not enabled or configured properly')
|
||||
}
|
||||
|
||||
# Check to see if SSL Certificates are properly defined.
|
||||
if ($ssl == 'true') {
|
||||
if ($ssl_cert == undef) or ($ssl_key == undef) {
|
||||
fail('nginx: SSL certificate/key (ssl_cert/ssl_cert) and/or SSL Private must be defined and exist on the target system(s)')
|
||||
}
|
||||
}
|
||||
|
||||
# Use the File Fragment Pattern to construct the configuration files.
|
||||
# Create the base configuration file reference.
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-001":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_header.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
# Create the default location reference for the vHost
|
||||
nginx::resource::location {"${name}-default":
|
||||
ensure => $ensure,
|
||||
vhost => $name,
|
||||
ssl => $ssl,
|
||||
location => '/',
|
||||
proxy => $proxy,
|
||||
www_root => $www_root,
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
# Create a proper file close stub.
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-699":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_footer.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
|
||||
# Create SSL File Stubs if SSL is enabled
|
||||
if ($ssl == 'true') {
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-700-ssl":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_ssl_header.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
file { "${nginx::config::nx_temp_dir}/nginx.d/${name}-999-ssl":
|
||||
ensure => $ensure ? {
|
||||
'absent' => absent,
|
||||
default => 'file',
|
||||
},
|
||||
content => template('nginx/vhost/vhost_footer.erb'),
|
||||
notify => Class['nginx::service'],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
# This module manages NGINX service management and vhost rebuild
|
||||
#
|
||||
# Parameters:
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# There are no default parameters for this class.
|
||||
#
|
||||
# Actions:
|
||||
#
|
||||
|
@ -21,11 +21,11 @@ class nginx::service {
|
|||
}
|
||||
service { "nginx":
|
||||
ensure => running,
|
||||
enable => true,
|
||||
enable => true,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
subscribe => Class['nginx'],
|
||||
hasrestart => true,
|
||||
subscribe => Class['nginx'],
|
||||
}
|
||||
|
||||
Exec['rebuild-nginx-vhosts'] ~> Service['nginx']
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue