From 292d79ac96c44d09e14935b702cbe93fd35aeeb9 Mon Sep 17 00:00:00 2001 From: john-scalingo <159253584+john-scalingo@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:51:58 +0200 Subject: [PATCH] fix(vrrp_instances) Do not duplicate the 'notify_master' script (#154) * fix(vrrp_instances) Do not duplicate the 'notify_master' script --- CHANGELOG.md | 2 ++ spec/resources/vrrp_instance_spec.rb | 21 ++++++++++++++++----- templates/vrrp_instance.conf.erb | 3 --- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43c68a3..68d2aea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the keepalived cookboo ## Unreleased +- Fixed a bug that duplicated the `notify_master` script in a `vrrp_instance` + ## 6.0.18 - *2024-05-03* ## 6.0.17 - *2024-05-03* diff --git a/spec/resources/vrrp_instance_spec.rb b/spec/resources/vrrp_instance_spec.rb index d84786d..866c719 100644 --- a/spec/resources/vrrp_instance_spec.rb +++ b/spec/resources/vrrp_instance_spec.rb @@ -236,24 +236,35 @@ def vrrp_instance_file_name(name) end it('should render a config file with the notify_stop correctly') do - is_expected.to render_file(file_name).with_content(%r{notify_stop\s/path/to_stop\.sh}) + is_expected.to render_file(file_name).with_content { |s| + expect(s.scan(%r{notify_stop\s/path/to_stop\.sh}).size).to eq(1) + } end it('should render a config file with the notify_master correctly') do - is_expected.to render_file(file_name).with_content(%r{notify_master\s/path/to_master\.sh}) + is_expected.to render_file(file_name).with_content { |s| + expect(s.scan(%r{notify_master\s/path/to_master\.sh}).size).to eq(1) + } end it('should render a config file with the notify_backup correctly') do - is_expected.to render_file(file_name).with_content(%r{notify_backup\s/path/to_backup\.sh}) + is_expected.to render_file(file_name).with_content { |s| + expect(s.scan(%r{notify_backup\s/path/to_backup\.sh}).size).to eq(1) + } end it('should render a config file with the notify_fault correctly') do - is_expected.to render_file(file_name).with_content(%r{notify_fault\s/path/fault\.sh}) + is_expected.to render_file(file_name).with_content { |s| + expect(s.scan(%r{notify_fault\s/path/fault\.sh}).size).to eq(1) + } end it('should render a config file with the notify correctly') do - is_expected.to render_file(file_name).with_content(%r{notify\s/path/notify\.sh}) + is_expected.to render_file(file_name).with_content { |s| + expect(s.scan(%r{notify\s/path/notify\.sh}).size).to eq(1) + } end + it('should render a config file with the smtp_alert set to true') do is_expected.to render_file(file_name).with_content(/smtp_alert\strue/) end diff --git a/templates/vrrp_instance.conf.erb b/templates/vrrp_instance.conf.erb index dbf047c..86d9441 100644 --- a/templates/vrrp_instance.conf.erb +++ b/templates/vrrp_instance.conf.erb @@ -124,9 +124,6 @@ vrrp_instance <%= @instance_name %> { <% if @notify_master %> notify_master <%= @notify_master.to_s %> <% end %> -<% if @notify_master %> - notify_master <%= @notify_master.to_s %> -<% end %> <% if @notify_backup %> notify_backup <%= @notify_backup.to_s %> <% end %>