Skip to content

Commit

Permalink
Support custom lines in /etc/resolv.conf
Browse files Browse the repository at this point in the history
Fixes #41
  • Loading branch information
treydock committed Nov 16, 2023
1 parent 0801970 commit 1a0b637
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand All @@ -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',
Expand Down
20 changes: 20 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' }
Expand Down
3 changes: 3 additions & 0 deletions templates/resolv.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%>

0 comments on commit 1a0b637

Please sign in to comment.