Skip to content

Commit

Permalink
allow setting process parameters for track_process
Browse files Browse the repository at this point in the history
With this, setting parameter to check for vrrp processes is possible.
  • Loading branch information
trefzer committed Oct 26, 2024
1 parent 610ea91 commit b34f1a4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
4 changes: 3 additions & 1 deletion REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1776,9 +1776,11 @@ The following parameters are available in the `keepalived::vrrp::track_process`

##### <a name="-keepalived--vrrp--track_process--proc_name"></a>`proc_name`

Data type: `String[1]`
Data type: `Variant[String[1], Array[String[1],1]]`

process name to track
use an Array configuration to specify process parameters (first element needs to
be the process name).

##### <a name="-keepalived--vrrp--track_process--weight"></a>`weight`

Expand Down
7 changes: 5 additions & 2 deletions manifests/vrrp/track_process.pp
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#
# @summary Configure the process tracker
#
# @param proc_name process name to track
# @param proc_name
# process name to track
# use an Array configuration to specify process parameters (first element needs to
# be the process name).
#
# @param weight The weight that should add to the instance.
#
Expand All @@ -18,7 +21,7 @@
# @param param_match Set inital if command has no parameters or use partial if first n parameters match
#
define keepalived::vrrp::track_process (
String[1] $proc_name,
Variant[String[1], Array[String[1],1]] $proc_name,
Optional[Integer[0]] $weight = undef,
Integer[0] $quorum = 1,
Optional[Integer[0]] $delay = undef,
Expand Down
17 changes: 17 additions & 0 deletions spec/defines/keepalived_vrrp_track_process_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@
end
end

describe 'with array parameter proc_name' do
let(:params) do
{
proc_name: ['MYPROCNAME','PARAM 1']

Check failure on line 43 in spec/defines/keepalived_vrrp_track_process_spec.rb

View workflow job for this annotation

GitHub Actions / Puppet / Static validations

Layout/SpaceAfterComma: Space missing after comma. (https://rubystyle.guide#spaces-operators)
}
end

it { is_expected.to create_keepalived__vrrp__track_process('_PROC_NAME_') }

it do
is_expected.to \
contain_concat__fragment('keepalived.conf_vrrp_track_process__PROC_NAME_').with(
'content' => %r{process.*MYPROCNAME.*PARAM 1}
)
end
end

describe 'with parameter weight' do
let(:params) do
{
Expand Down
6 changes: 5 additions & 1 deletion templates/vrrp_track_process.epp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%- | String $name,
String $proc_name,
Variant[String[1], Array[String[1],1]] $proc_name,
Optional[Integer] $weight,
Optional[Integer] $quorum,
Optional[Integer] $delay,
Expand All @@ -9,7 +9,11 @@
Optional[Boolean] $full_command
| -%>
vrrp_track_process <%= $name %> {
<%- if $proc_name =~ String { -%>
process "<%= $proc_name %>"
<%- } else { -%>
process "<%= $proc_name.join('" "') %>"
<%- } -%>
<%- if $weight { -%>
weight <%= $weight %>
<%- } -%>
Expand Down

0 comments on commit b34f1a4

Please sign in to comment.