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 apply_prefix argument to service object to fix issue #227 #228

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions manifests/object.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# [*apply_target*]
# An object type on which to target the apply rule. Valid values are `Host` and `Service`. Defaults to `Host`.
#
# [*apply_prefix*]
# An optional name prefix to use when using a loop apply statement.
#
# [*import*]
# A sorted list of templates to import in this object. Defaults to an empty array.
#
Expand Down Expand Up @@ -54,6 +57,7 @@
$template = false,
$apply = false,
$apply_target = undef,
$apply_prefix = undef,
$import = [],
$assign = [],
$ignore = [],
Expand Down Expand Up @@ -91,6 +95,7 @@
unless is_bool($apply) { validate_re($apply, '^.+\s+(=>\s+.+\s+)?in\s+.+$') }
if $apply_target { validate_re($apply_target, ['^Host$', '^Service$'],
"${apply_target} isn't supported. Valid values are 'Host' and 'Service'.") }
if $apply_prefix { validate_string($apply_prefix) }
validate_array($import)
validate_array($assign)
validate_array($ignore)
Expand Down
6 changes: 6 additions & 0 deletions manifests/object/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
# Dispose an apply instead an object if set to 'true'. Value is taken as statement,
# i.e. 'vhost => config in host.vars.vhosts'. Defaults to false.
#
# [*apply_prefix*]
# An optional name prefix to use when using a loop apply statement.
#
# [*assign*]
# Assign user group members using the group assign rules.
#
Expand Down Expand Up @@ -185,6 +188,7 @@
$icon_image = undef,
$icon_image_alt = undef,
$apply = false,
$apply_prefix = undef,
$assign = [],
$ignore = [],
$import = [],
Expand Down Expand Up @@ -231,6 +235,7 @@
if $action_url { validate_string ($action_url) }
if $icon_image { validate_absolute_path ($icon_image) }
if $icon_image_alt { validate_string ($icon_image_alt) }
if $apply_prefix { validate_string($apply_prefix) }


# compose the attributes
Expand Down Expand Up @@ -271,6 +276,7 @@
import => $import,
apply => $apply,
apply_target => 'Host',
apply_prefix => $apply_prefix,
assign => $assign,
ignore => $ignore,
template => $template,
Expand Down
2 changes: 1 addition & 1 deletion templates/object.conf.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<% if @apply.is_a?(String) %>apply <%= @object_type -%> for (<%= @apply %>) to <%= @apply_target -%> {
<% if @apply.is_a?(String) %>apply <%= @object_type -%> <% if @apply_prefix %>"<%= @apply_prefix %>" <% end %>for (<%= @apply %>) to <%= @apply_target -%> {
<% else -%>
<% if @apply %>apply<% else -%>
<% if @template %>template<% else %>object<% end -%>
Expand Down