Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'ensure' parameter to resource::upstream::member. #673

Merged
merged 4 commits into from
Aug 31, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manifests/resource/upstream/member.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#
#
# Parameters:
# [*ensure*] - Enables or disables the specified member (present|absent)
# [*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
Expand All @@ -20,6 +21,7 @@
# Exporting the resource on a upstream member server:
#
# @@nginx::resource::upstream::member { $::fqdn:
# ensure => present,
# upstream => 'proxypass',
# server => $::ipaddress,
# port => '3000',
Expand All @@ -35,12 +37,22 @@
define nginx::resource::upstream::member (
$upstream,
$server,
$ensure = 'present',
$port = '80',
$upstream_fail_timeout = '10s',
) {

validate_re($ensure, '^(present|absent)$',
"${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.")

$ensure_real = $ensure ? {
'absent' => absent,
default => present,
}

# Uses: $server, $port, $upstream_fail_timeout
concat::fragment { "${upstream}_upstream_member_${name}":
ensure => $ensure_real,
target => "${::nginx::config::conf_dir}/conf.d/${upstream}-upstream.conf",
order => 40,
content => template('nginx/conf.d/upstream_member.erb'),
Expand Down