Skip to content

Commit

Permalink
Revert "Added ngnix::resources::upstream::member"
Browse files Browse the repository at this point in the history
Upstream members can no longer be exported and collected.

The change in voxpupuli#331 was fundamentally broken. I have therefore reverted
it as it shouldn't of been merged.

Essentially you can't use ensure with this change - meaning you can no
longer REMOVE an nginx config from the system - which is part of the
tests and also sane module practice.

The idea was nice - but the implementation broke things. This reverts
back to a good state, without modifying any tests where tests pass again
with the recent commits.

This reverts commit ebf3e4e.
  • Loading branch information
leepa committed Jun 12, 2014
1 parent 96c995b commit 2741361
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 85 deletions.
40 changes: 6 additions & 34 deletions manifests/resource/upstream.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
# Parameters:
# [*members*] - Array of member URIs for NGINX to connect to. Must follow valid NGINX syntax.
# If omitted, individual members should be defined with nginx::resource::upstream::member
# [*ensure*] - Enables or disables the specified location (present|absent)
# [*upstream_cfg_prepend*] - It expects a hash with custom directives to put before anything else inside upstream
# [*upstream_fail_timeout*] - Set the fail_timeout for the upstream. Default is 10 seconds - As that is what Nginx does normally.
Expand Down Expand Up @@ -39,58 +38,31 @@
# upstream_cfg_prepend => $my_config,
# }
define nginx::resource::upstream (
$members = undef,
$members,
$ensure = 'present',
$upstream_cfg_prepend = undef,
$upstream_fail_timeout = '10s',
) {

if $members != undef {
validate_array($members)
}
validate_array($members)
validate_re($ensure, '^(present|absent)$',
"${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.")
if ($upstream_cfg_prepend != undef) {
validate_hash($upstream_cfg_prepend)
}

Concat {
File {
owner => 'root',
group => 'root',
mode => '0644',
}

concat { "/etc/nginx/conf.d/${name}-upstream.conf":
file { "/etc/nginx/conf.d/${name}-upstream.conf":
ensure => $ensure ? {
'absent' => absent,
'file' => present,
default => present,
default => 'file',
},
content => template('nginx/conf.d/upstream.erb'),
notify => Class['nginx::service'],
}

# Uses: $name, $upstream_cfg_prepend
concat::fragment { "${name}_upstream_header":
target => "/etc/nginx/conf.d/${name}-upstream.conf",
order => 10,
content => template('nginx/conf.d/upstream_header.erb'),
}

if $members != undef {
# Uses: $members, $upstream_fail_timeout
concat::fragment { "${name}_upstream_members":
target => "/etc/nginx/conf.d/${name}-upstream.conf",
order => 50,
content => template('nginx/conf.d/upstream_members.erb'),
}
} else {
# Collect exported members:
Nginx::Resource::Upstream::Member <<| upstream == $name |>>
}

concat::fragment { "${name}_upstream_footer":
target => "/etc/nginx/conf.d/${name}-upstream.conf",
order => 90,
content => "}\n",
}
}
48 changes: 0 additions & 48 deletions manifests/resource/upstream/member.pp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ upstream <%= @name %> {
<% end -%>
<% end -%>
<% end -%><% end -%>
<% @members.each do |i| %>
server <%= i %> fail_timeout=<%= @upstream_fail_timeout %>;<% end %>
}
1 change: 0 additions & 1 deletion templates/conf.d/upstream_member.erb

This file was deleted.

2 changes: 0 additions & 2 deletions templates/conf.d/upstream_members.erb

This file was deleted.

0 comments on commit 2741361

Please sign in to comment.