A module for creating a resolv.conf file
Signed-off-by: Ossi Salmi <osalmi@iki.fi>
This commit is contained in:
parent
de5ed0ff7c
commit
3c0e4d26c2
2 changed files with 37 additions and 0 deletions
31
resolver/manifests/init.pp
Normal file
31
resolver/manifests/init.pp
Normal file
|
@ -0,0 +1,31 @@
|
|||
# Class: resolver
|
||||
#
|
||||
# This class handles configuring /etc/resolv.conf
|
||||
#
|
||||
# Parameters:
|
||||
# $domainname: The default domain
|
||||
#
|
||||
# $searchpath: Array of domains to search
|
||||
#
|
||||
# $nameservers: List of nameservers to search
|
||||
#
|
||||
# Actions:
|
||||
# Configures the /etc/resolv.conf file according to parameters
|
||||
#
|
||||
# Requires:
|
||||
#
|
||||
# Sample Usage:
|
||||
# class { 'resolver':
|
||||
# domainname => "mydomain",
|
||||
# searchpath => ['mydomain', 'test.mydomain'],
|
||||
# nameservers => ['192.168.1.100', '192.168.1.101', '192.168.1.102'],
|
||||
# }
|
||||
#
|
||||
class resolver($domainname = "", $searchpath = "", $nameservers ) {
|
||||
file { "/etc/resolv.conf":
|
||||
owner => root,
|
||||
group => root,
|
||||
mode => 644,
|
||||
content => template("resolver/resolv.conf.erb"),
|
||||
}
|
||||
}
|
6
resolver/templates/resolv.conf.erb
Normal file
6
resolver/templates/resolv.conf.erb
Normal file
|
@ -0,0 +1,6 @@
|
|||
<% if !domainname.empty? %>domain <%= domainname %>
|
||||
<% end -%>
|
||||
<% if !searchpath.empty? %>search <%= searchpath.join(" ") %>
|
||||
<% end -%>
|
||||
<% nameservers.each do |ns| %>nameserver <%= ns %>
|
||||
<% end -%>
|
Loading…
Add table
Reference in a new issue