Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2016.4.x
- Puppet >= 4.10.0 < 8.0.0
- , , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppetfinland-resolver', '1.0.0'
Learn more about managing modules with a PuppetfileDocumentation
puppet-resolver
Manage DNS resolver configurations on Linux and Windows systems. The module supports several different methods of DNS resolver configuration:
- dhclient
- sysconfig
- systemd-resolved
- windows
Other methods can be added relatively easily.
Sane defaults for the DNS resolver method have been provided for all supported operating systems:
- Ubuntu 16.04 (dhclient)
- Ubuntu 18.04, 20.04, 22.04 (systemd-resolved)
- CentOS/Red Hat 7 (sysconfig)
- CentOS/Rocky/Red Hat 8 (sysconfig)
- Windows (windows)
However, should the defaults fail the method can be selected manually.
General usage
In most cases you should be able to just use the defaults:
class { 'resolver':
servers => ['10.10.10.1', '10.10.10.2'],
domains => ['example.org', 'example.com'],
}
Note that some methods do not supports the domains parameter at all, or may only support it partially.
Note that method defaults only works for the officially supported operating systems, that is, those that have proper module-level Hiera data. On unsupported operating systems catalog configuration will fail unless you explicitly define the method parameter.
Also note that the default methods may not be correct in all cases. For example some Cloud images may be configured to use different method out of box than what this module expects.
Methods
dhclient
Example usage:
class { 'resolver':
method => 'dhclient',
servers => ['10.10.10.1', '10.10.10.2'],
}
Notes:
- The domains parameter is not supported
sysconfig
Example usage:
class { 'resolver':
method => 'sysconfig',
servers => ['10.10.10.1', '10.10.10.2'],
domains => ['example.org'],
interface => 'eth0',
}
Notes:
- The domains parameter is optional
- If interface is not defined, Puppet defaults to using the primary network interface ($facts['networking']['primary'])
- If more than one domain is defined, only the first one is used
systemd-resolved
To configure global settings:
class { 'resolver':
method => 'systemd-resolved',
servers => ['10.10.10.1', '10.10.10.2'],
domains => ['example.org', 'example.com'],
}
Note that global settings may not have the intended effect as per-link settings may take precedence over them.
To configure settings for an interface (this is a wrapper for resolver::systemd_resolved::interface):
class { 'resolver':
method => 'systemd-resolved',
servers => ['10.10.10.1', '10.10.10.2'],
domains => ['example.org', 'example.com'],
interface => 'eth0',
}
If you need to configure resolvers for more than one interface you can use the resolver::systemd_resolved::interface define:
resolver::systemd_resolved::interface { 'eth0':
servers => ['10.10.10.1', '10.10.10.2'],
domains => ['example.org', 'example.com'],
interface => 'eth0',
}
resolver::systemd_resolved::interface { 'eth1':
servers => ['10.20.20.1', '10.20.20.2'],
domains => ['foo.org', 'bar.com'],
interface => 'eth1',
}
Notes:
- The domains parameter is optional
- Multiple domains are supported
- If systemd-resolved has already obtained domain information from elsewhere it does not get overwritten (yet). This can cause unexpected behavior and/or flickering on Puppet runs.
windows
Example usage:
class { 'resolver':
method => 'windows,
servers => ['10.10.10.1', '10.10.10.2'],
}
Notes:
- The domains parameter is not supported
Custom facts
This module contains one custom fact, systemd_resolve_status. If systemd-resolved is running it should contain a hash with DNS settings for each interface. For example:
{
Global => {
}
eth0 => {
dns_domain => [
"example.org"
],
dns_servers => [
"10.10.10.1",
"10.10.10.2"
]
},
eth1 => {
dns_domain => [
"example.com"
],
dns_servers => [
"10.20.20.1",
"10.20.20.2"
]
},
eth2 => {
dns_servers => [
"10.30.30.1",
"10.30.30.2"
]
},
eth3 => {
}
}
Dependencies
- puppetlabs/dsc (>= 1.0.0 < 2.0.0)
- puppetlabs/cron_core (>= 8.0.0 < 9.0.0)
Copyright 2019 OpenVPN, Inc and 2019 Samuli Seppänen Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.