voxpupuli / puppet-system

Manage Linux system resources and services from hiera configuration
https://forge.puppet.com/puppet/system
Apache License 2.0
63 stars 47 forks source link

template/dns.erb #38

Closed otheus closed 6 years ago

otheus commented 6 years ago

Fixes issue #37

alexjfisher commented 6 years ago

@otheus Thanks. It might be possible to simplify this though. Does

<%- unless @domains.empty? -%>
search <%= @domains.split(' ') -%>
<%- end -%>
<%- unless @options.empty? -%>
options <%= @options.split(' ') -%>
<%- end -%>

work?

otheus commented 6 years ago

I think @options.empty? will throw an exception if options is not defined (or perhaps in older versions of puppet). I will test and get back to you.

otheus commented 6 years ago

Found another bug. Don't merge yet.

otheus commented 6 years ago

@alexjfisher I think you menat .join() here, not .split(). And if options is omitted, the ERB fails without the nil check. The validate_array() in the new code is also incorrect, since "options" are actually optional. New commit forthcoming.

alexjfisher commented 6 years ago

@otheus Yeah, I did mean join (I often get those mixed up)! You're correct in thinking I had seen the validate_array code. If that's wrong, then you will need to check it exists.

alexjfisher commented 6 years ago

You probably don't need the defined? though. <% if @domains && @domains.any? -%> should do.