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

Allow service definition without explicit group #78

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ page.
* `protocol` - optional - defaults to "tcp"
* `user` - optional - defaults to "root"
* `group` - optional - defaults to "root"
* `use_default_group` - optional - set to "false" to prevent using the OS specific default group for the service, defaults to "true"
* `instances` - optional - defaults to "UNLIMITED"
* `wait` - optional - based on $protocol will default to "yes" for udp and "no" for tcp
* `service_type` - optional - type setting in xinetd
Expand Down
6 changes: 5 additions & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# $protocol - optional - defaults to "tcp"
# $user - optional - defaults to "root"
# $group - optional - defaults to "root"
# $use_default_group - optional - defaults to true
# $groups - optional - defaults to "yes"
# $instances - optional - defaults to "UNLIMITED"
# $only_from - optional
Expand Down Expand Up @@ -76,6 +77,7 @@
$disable = 'no',
$flags = undef,
$group = undef,
$use_default_group = true,
$groups = 'yes',
$instances = 'UNLIMITED',
$per_source = undef,
Expand All @@ -97,13 +99,15 @@

include ::xinetd

validate_bool($use_default_group)

if $user {
$_user = $user
} else {
$_user = $xinetd::params::default_user
}

if $group {
if $group or bool2num($use_default_group) == 0 {
$_group = $group
} else {
$_group = $xinetd::params::default_group
Expand Down
27 changes: 27 additions & 0 deletions spec/defines/xinetd_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@
}
end

describe 'with group' do
let :params do
default_params.merge({'group' => 'foo'})
end
it {
should contain_file('/etc/xinetd.d/httpd').with_content(/group\s*=\s*foo/)
}
end

describe 'with use_default_group true' do
let :params do
default_params.merge({'use_default_group' => true})
end
it {
should contain_file('/etc/xinetd.d/httpd').with_content(/group\s*=\s*root/)
}
end

describe 'with use_default_group false' do
let :params do
default_params.merge({'use_default_group' => false})
end
it {
should contain_file('/etc/xinetd.d/httpd').without_content(/group\s*=/)
}
end

describe 'without log_on_<success|failure>' do
let :params do
default_params
Expand Down
2 changes: 2 additions & 0 deletions templates/service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ service <%= @service_name %>
protocol = <%= @protocol %>
wait = <%= @_wait %>
user = <%= @_user %>
<% if @_group -%>
group = <%= @_group %>
<% end -%>
groups = <%= @groups %>
server = <%= @server %>
<% if @bind -%>
Expand Down