diff --git a/manifests/vrrp/instance.pp b/manifests/vrrp/instance.pp index dab36e53e..9e1afaee2 100644 --- a/manifests/vrrp/instance.pp +++ b/manifests/vrrp/instance.pp @@ -81,7 +81,9 @@ # Authentication password. # # @param track_script -# Define which script to run to track service states. +# Define which scripts to run to track service states. +# May be specified either as a String with a single Scriptname, +# or as an Array of Strings with multiple Scriptnames. # # @param track_process # Define which process trackers to run. diff --git a/spec/defines/keepalived_vrrp_instance_spec.rb b/spec/defines/keepalived_vrrp_instance_spec.rb index f7d9a6518..47767a580 100644 --- a/spec/defines/keepalived_vrrp_instance_spec.rb +++ b/spec/defines/keepalived_vrrp_instance_spec.rb @@ -353,7 +353,7 @@ } end - describe 'with parameter track_script' do + describe 'with parameter track_script as an Array of Strings' do let(:params) do mandatory_params.merge( track_script: ['_VALUE_'] @@ -370,6 +370,23 @@ } end + describe 'with parameter track_script as a single String' do + let(:params) do + mandatory_params.merge( + track_script: '_VALUE_' + ) + end + + it { is_expected.to create_keepalived__vrrp__instance('_NAME_') } + + it { + is_expected.to \ + contain_concat__fragment('keepalived.conf_vrrp_instance__NAME_').with( + 'content' => %r!^ track_script {\n _VALUE_! + ) + } + end + describe 'with parameter lvs_interface' do let(:params) do mandatory_params.merge( diff --git a/templates/vrrp_instance.erb b/templates/vrrp_instance.erb index 31f99fb34..cc5da706f 100644 --- a/templates/vrrp_instance.erb +++ b/templates/vrrp_instance.erb @@ -100,7 +100,7 @@ vrrp_instance <%= @_name %> { <%- unless @track_script.empty? -%> track_script { - <%- @track_script.each do |track| -%> + <%- Array(@track_script).flatten.each do |track| -%> <%= track %> <%- end -%> }