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