1 # **NOTE: THIS IS A [PRIVATE](https://github.com/puppetlabs/puppetlabs-stdlib#assert_private) CLASS**
3 # This class provides an abstract way to trigger resolved.
4 # Each parameters correspond to resolved.conf(5):
5 # https://www.freedesktop.org/software/systemd/man/resolved.conf.html
8 # The state that the ``resolved`` service should be in
11 # A space-separated list of IPv4 and IPv6 addresses to use as system DNS servers.
12 # DNS requests are sent to one of the listed DNS servers in parallel to suitable
13 # per-link DNS servers acquired from systemd-networkd.service(8) or set at runtime
14 # by external applications. requires puppetlabs-inifile
17 # A space-separated list of IPv4 and IPv6 addresses to use as the fallback DNS
18 # servers. Any per-link DNS servers obtained from systemd-networkd take
19 # precedence over this setting. requires puppetlabs-inifile
22 # A space-separated list of domains host names or IP addresses to be used
23 # systemd-resolved take precedence over this setting.
26 # Takes a boolean argument or "resolve".
28 # @param multicast_dns
29 # Takes a boolean argument or "resolve".
32 # Takes a boolean argument or "allow-downgrade".
35 # Takes a boolean argument.
37 # @param dns_stub_listener
38 # Takes a boolean argument or one of "udp" and "tcp".
40 # @param use_stub_resolver
41 # Takes a boolean argument. When "false" (default) it uses /var/run/systemd/resolve/resolv.conf
42 # as /etc/resolv.conf. When "true", it uses /var/run/systemd/resolve/stub-resolv.conf
44 class systemd::resolved (
45 Enum['stopped','running'] $ensure = $systemd::resolved_ensure,
46 Optional[Variant[Array[String],String]] $dns = $systemd::dns,
47 Optional[Variant[Array[String],String]] $fallback_dns = $systemd::fallback_dns,
48 Optional[Variant[Array[String],String]] $domains = $systemd::domains,
49 Optional[Variant[Boolean,Enum['resolve']]] $llmnr = $systemd::llmnr,
50 Optional[Variant[Boolean,Enum['resolve']]] $multicast_dns = $systemd::multicast_dns,
51 Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec = $systemd::dnssec,
52 Boolean $cache = $systemd::cache,
53 Optional[Variant[Boolean,Enum['udp', 'tcp']]] $dns_stub_listener = $systemd::dns_stub_listener,
54 Boolean $use_stub_resolver = $systemd::use_stub_resolver,
59 $_enable_resolved = $ensure ? {
65 service { 'systemd-resolved':
67 enable => $_enable_resolved,
70 $_resolv_conf_target = $use_stub_resolver ? {
71 true => '/run/systemd/resolve/stub-resolv.conf',
72 default => '/run/systemd/resolve/resolv.conf',
74 file { '/etc/resolv.conf':
76 target => $_resolv_conf_target,
77 require => Service['systemd-resolved'],
84 $_dns = join($dns, ' ')
91 path => '/etc/systemd/resolved.conf',
92 notify => Service['systemd-resolved'],
97 if $fallback_dns =~ String {
98 $_fallback_dns = $fallback_dns
100 $_fallback_dns = join($fallback_dns, ' ')
102 ini_setting{ 'fallback_dns':
104 value => $_fallback_dns,
105 setting => 'FallbackDNS',
106 section => 'Resolve',
107 path => '/etc/systemd/resolved.conf',
108 notify => Service['systemd-resolved'],
113 if $domains =~ String {
116 $_domains = join($domains, ' ')
118 ini_setting{ 'domains':
121 setting => 'Domains',
122 section => 'Resolve',
123 path => '/etc/systemd/resolved.conf',
124 notify => Service['systemd-resolved'],
135 ini_setting{ 'llmnr':
139 section => 'Resolve',
140 path => '/etc/systemd/resolved.conf',
141 notify => Service['systemd-resolved'],
145 $_multicast_dns = $multicast_dns ? {
148 default => $multicast_dns,
152 ini_setting{ 'multicast_dns':
154 value => $_multicast_dns,
155 setting => 'MulticastDNS',
156 section => 'Resolve',
157 path => '/etc/systemd/resolved.conf',
158 notify => Service['systemd-resolved'],
162 $_dnssec = $dnssec ? {
169 ini_setting{ 'dnssec':
173 section => 'Resolve',
174 path => '/etc/systemd/resolved.conf',
175 notify => Service['systemd-resolved'],
185 ini_setting{ 'cache':
189 section => 'Resolve',
190 path => '/etc/systemd/resolved.conf',
191 notify => Service['systemd-resolved'],
195 $_dns_stub_listener = $dns_stub_listener ? {
198 default => $dns_stub_listener,
201 if $_dns_stub_listener {
202 ini_setting{ 'dns_stub_listener':
204 value => $_dns_stub_listener,
205 setting => 'DNSStubListener',
206 section => 'Resolve',
207 path => '/etc/systemd/resolved.conf',
208 notify => Service['systemd-resolved'],