Skip to content

Commit 6b02de8

Browse files
author
Morgan Haskel
committed
Merge pull request #35 from dvorak/log_on_operators
Allow configuring log_on_* operator
2 parents bbcebf2 + 3c2417d commit 6b02de8

File tree

3 files changed

+78
-25
lines changed

3 files changed

+78
-25
lines changed

manifests/service.pp

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77
# $ensure - optional - defaults to 'present'
88
# $log_on_success - optional - may contain any combination of
99
# 'PID', 'HOST', 'USERID', 'EXIT', 'DURATION', 'TRAFFIC'
10+
# $log_on_success_operator - optional - defaults to '+='. This is whether or
11+
# not values specified will be add, set or remove
12+
# from the default.
1013
# $log_on_failure - optional - may contain any combination of
1114
# 'HOST', 'USERID', 'ATTEMPT'
15+
# $log_on_failure_operator - optional - defaults to '+='. This is whether or
16+
# not values specified will be add, set or remove
17+
# from the default.
1218
# $service_type - optional - type setting in xinetd
1319
# may contain any combinarion of 'RPC', 'INTERNAL',
1420
# 'TCPMUX/TCPMUXPLUS', 'UNLISTED'
@@ -56,29 +62,31 @@
5662
define xinetd::service (
5763
$port,
5864
$server,
59-
$ensure = present,
60-
$log_on_success = undef,
61-
$log_on_failure = undef,
62-
$service_type = undef,
63-
$service_name = $title,
64-
$cps = undef,
65-
$disable = 'no',
66-
$flags = undef,
67-
$group = 'root',
68-
$groups = 'yes',
69-
$instances = 'UNLIMITED',
70-
$per_source = undef,
71-
$protocol = 'tcp',
72-
$server_args = undef,
73-
$socket_type = 'stream',
74-
$user = 'root',
75-
$only_from = undef,
76-
$wait = undef,
77-
$xtype = undef,
78-
$no_access = undef,
79-
$access_times = undef,
80-
$log_type = undef,
81-
$bind = undef
65+
$ensure = present,
66+
$log_on_success = undef,
67+
$log_on_success_operator = '+=',
68+
$log_on_failure = undef,
69+
$log_on_failure_operator = '+=',
70+
$service_type = undef,
71+
$service_name = $title,
72+
$cps = undef,
73+
$disable = 'no',
74+
$flags = undef,
75+
$group = 'root',
76+
$groups = 'yes',
77+
$instances = 'UNLIMITED',
78+
$per_source = undef,
79+
$protocol = 'tcp',
80+
$server_args = undef,
81+
$socket_type = 'stream',
82+
$user = 'root',
83+
$only_from = undef,
84+
$wait = undef,
85+
$xtype = undef,
86+
$no_access = undef,
87+
$access_times = undef,
88+
$log_type = undef,
89+
$bind = undef
8290
) {
8391

8492
include xinetd
@@ -109,7 +117,9 @@
109117
# - $only_from
110118
# - $per_source
111119
# - $log_on_success
120+
# - $log_on_success_operator
112121
# - $log_on_failure
122+
# - $log_on_failure_operator
113123
# - $cps
114124
# - $flags
115125
# - $xtype

spec/defines/xinetd_service_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,47 @@
4343
should contain_file('/etc/xinetd.d/httpd').with_ensure('absent')
4444
}
4545
end
46+
47+
describe 'without log_on_<success|failure>' do
48+
let :params do
49+
default_params
50+
end
51+
it {
52+
should contain_file('/etc/xinetd.d/httpd').without_content(/log_on_success/)
53+
should contain_file('/etc/xinetd.d/httpd').without_content(/log_on_failure/)
54+
}
55+
end
56+
57+
describe 'with log_on_<success|failure> w/default operator' do
58+
let :params do
59+
default_params.merge({
60+
:log_on_success => 'SUCCESS_TEST',
61+
:log_on_failure => 'FAILURE_TEST',
62+
})
63+
end
64+
it {
65+
should contain_file('/etc/xinetd.d/httpd').with_content(
66+
/log_on_success\s*\+=\s*SUCCESS_TEST/)
67+
should contain_file('/etc/xinetd.d/httpd').with_content(
68+
/log_on_failure\s*\+=\s*FAILURE_TEST/)
69+
}
70+
end
71+
72+
describe 'with log_on_<success|failure> with equal operator' do
73+
let :params do
74+
default_params.merge({
75+
:log_on_success => 'SUCCESS_TEST',
76+
:log_on_failure => 'FAILURE_TEST',
77+
:log_on_success_operator => '=',
78+
:log_on_failure_operator => '=',
79+
})
80+
end
81+
it {
82+
should contain_file('/etc/xinetd.d/httpd').with_content(
83+
/log_on_success\s*\=\s*SUCCESS_TEST/)
84+
should contain_file('/etc/xinetd.d/httpd').with_content(
85+
/log_on_failure\s*\=\s*FAILURE_TEST/)
86+
}
87+
end
88+
4689
end

templates/service.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ service <%= @service_name %>
2828
per_source = <%= @per_source %>
2929
<% end -%>
3030
<% if @log_on_success -%>
31-
log_on_success += <%= @log_on_success %>
31+
log_on_success <%= @log_on_success_operator %> <%= @log_on_success %>
3232
<% end -%>
3333
<% if @log_on_failure -%>
34-
log_on_failure += <%= @log_on_failure %>
34+
log_on_failure <%= @log_on_failure_operator %> <%= @log_on_failure %>
3535
<% end -%>
3636
<% if @cps -%>
3737
cps = <%= @cps %>

0 commit comments

Comments
 (0)