diff --git a/manifests/init.pp b/manifests/init.pp index de0ded3..e99976f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -22,6 +22,9 @@ # @param sortlist # Optional array of sortlist entries # +# @param custom_lines +# Array of lines that will be added to the end of /etc/resolv.conf +# # @param resolver_config_file # Path to resolv.conf # @@ -47,6 +50,7 @@ Optional[Array[String[1]]] $search = undef, Optional[Stdlib::Fqdn] $domain = undef, Optional[Array[String[1]]] $sortlist = undef, + Array[String[1]] $custom_lines = [], Stdlib::Absolutepath $resolver_config_file = '/etc/resolv.conf', String[1] $resolver_config_file_ensure = 'file', String[1] $resolver_config_file_owner = 'root', diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index dc95b89..98a7983 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -433,6 +433,26 @@ } end + context 'with custom_lines defined' do + let :params do + { custom_lines: ['foo', 'bar'] } + end + + content = <<-END.gsub(%r{^\s+\|}, '') + |# This file is being maintained by Puppet. + |# DO NOT EDIT + |options rotate timeout:1 + |nameserver 8.8.8.8 + |nameserver 8.8.4.4 + |foo + |bar + END + + it { + is_expected.to contain_file('dnsclient_resolver_config_file').with_content(content) + } + end + context 'with parameter resolver_config_file_ensure not set to \'file\' \'present\' or \'absent\'' do let :params do { resolver_config_file_ensure: 'invalid' } diff --git a/templates/resolv.conf.erb b/templates/resolv.conf.erb index 03f72d3..d5555af 100644 --- a/templates/resolv.conf.erb +++ b/templates/resolv.conf.erb @@ -15,3 +15,6 @@ options<% @options.each do |option| %> <%= option %><% end %> <% @nameservers_slice.each do |nameserver| -%> nameserver <%= nameserver %> <% end -%> +<% @custom_lines.each do |custom_line| -%> +<%= custom_line %> +<% end -%>