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

Template headers repeated #73

Open
dsnt02518 opened this issue Jul 29, 2021 · 1 comment
Open

Template headers repeated #73

dsnt02518 opened this issue Jul 29, 2021 · 1 comment

Comments

@dsnt02518
Copy link

I'm seeing the _header.erb contents included twice in /etc/freshclam.conf and /etc/sysconfig/freshclam.
I think the problem stems from using ERB.new(...).result(binding) to render the included template directly, instead of scope.function_template(...).

The problem only seems to occur when applying via puppet agent, for some reason using puppet apply on the same catalog doesn't include the header twice.

I've locally found that the replacing the call as in the diff below gets identical and correct behaviour with both puppet apply and puppet agent:

diff --git a/modules/clamav/templates/clamav.conf.erb b/modules/clamav/templates/clamav.conf.erb
index cdd5ce6..b8d2ead 100644
--- a/modules/clamav/templates/clamav.conf.erb
+++ b/modules/clamav/templates/clamav.conf.erb
@@ -1,4 +1,4 @@
-<%= ERB.new(File.read(File.expand_path("_header.erb",File.dirname(file)))).result(binding) -%>
+<%= scope.function_template([File.expand_path("_header.erb",File.dirname(file))]) -%>
 
 <% @config_options.sort.each do |k,v| -%>
 <% Array(v).each do |av| -%>
diff --git a/modules/clamav/templates/sysconfig/freshclam.erb b/modules/clamav/templates/sysconfig/freshclam.erb
index 967280b..8fdfab1 100644
--- a/modules/clamav/templates/sysconfig/freshclam.erb
+++ b/modules/clamav/templates/sysconfig/freshclam.erb
@@ -1,3 +1,3 @@
-<%= ERB.new(File.read(File.expand_path("_header.erb",File.dirname(File.dirname(file))))).result(binding) -%>
+<%= scope.function_template([File.expand_path("_header.erb",File.dirname(File.dirname(file)))]) -%>
 
 FRESHCLAM_DELAY=<%= @freshclam_delay %>

@dsnt02518
Copy link
Author

Should have mentioned - I'm using puppet version 6.19.1 on CentOS 7.9, apologies!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant