2014-06-20 17:17:23 +02:00
|
|
|
# Define: nginx::resources::upstream::member
|
|
|
|
#
|
|
|
|
# Creates an upstream member inside the upstream block. Export this resource
|
|
|
|
# in all upstream member servers and collect them on the NGINX server.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Requirements:
|
|
|
|
# Requires storeconfigs on the Puppet Master to export and collect resources
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Parameters:
|
2015-08-28 22:07:23 +02:00
|
|
|
# [*ensure*] - Enables or disables the specified member (present|absent)
|
2014-06-20 17:17:23 +02:00
|
|
|
# [*upstream*] - The name of the upstream resource
|
|
|
|
# [*server*] - Hostname or IP of the upstream member server
|
|
|
|
# [*port*] - Port of the listening service on the upstream member
|
|
|
|
# [*upstream_fail_timeout*] - Set the fail_timeout for the upstream. Default is 10 seconds
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
#
|
|
|
|
# Exporting the resource on a upstream member server:
|
|
|
|
#
|
|
|
|
# @@nginx::resource::upstream::member { $::fqdn:
|
2015-08-28 22:07:23 +02:00
|
|
|
# ensure => present,
|
2014-06-20 17:17:23 +02:00
|
|
|
# upstream => 'proxypass',
|
|
|
|
# server => $::ipaddress,
|
|
|
|
# port => '3000',
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Collecting the resource on the NGINX server:
|
|
|
|
#
|
|
|
|
# nginx::resource::upstream { 'proxypass':
|
|
|
|
# ensure => present,
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
define nginx::resource::upstream::member (
|
|
|
|
$upstream,
|
|
|
|
$server,
|
2015-08-28 22:07:23 +02:00
|
|
|
$ensure = 'present',
|
2014-06-20 17:17:23 +02:00
|
|
|
$port = '80',
|
|
|
|
$upstream_fail_timeout = '10s',
|
|
|
|
) {
|
|
|
|
|
2015-08-28 22:07:23 +02:00
|
|
|
validate_re($ensure, '^(present|absent)$',
|
|
|
|
"${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.")
|
|
|
|
|
|
|
|
$ensure_real = $ensure ? {
|
|
|
|
'absent' => absent,
|
|
|
|
default => present,
|
|
|
|
}
|
|
|
|
|
2014-06-20 17:17:23 +02:00
|
|
|
# Uses: $server, $port, $upstream_fail_timeout
|
|
|
|
concat::fragment { "${upstream}_upstream_member_${name}":
|
2015-08-28 22:07:23 +02:00
|
|
|
ensure => $ensure_real,
|
2014-11-27 05:33:57 +01:00
|
|
|
target => "${::nginx::config::conf_dir}/conf.d/${upstream}-upstream.conf",
|
2014-06-20 17:17:23 +02:00
|
|
|
order => 40,
|
|
|
|
content => template('nginx/conf.d/upstream_member.erb'),
|
|
|
|
}
|
|
|
|
}
|