Skip to content

Commit

Permalink
Add parameter to select resolver
Browse files Browse the repository at this point in the history
When using systemd-resolver you can choose to link /etc/resolv.conf to
a "standard" resolv.conf or to a "stub-resolv.conf" that uses 127.0.0.53
resolver provided by it.
  • Loading branch information
amateo committed Jul 19, 2018
1 parent 591084a commit d1c2ec3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ systemd::multicast_dns: ~
systemd::dnssec: ~
systemd::cache: false
systemd::dns_stub_listener: ~
systemd::use_stub_resolver: false
systemd::manage_networkd: false
systemd::networkd_ensure: 'running'
systemd::manage_timesyncd: false
Expand Down
4 changes: 4 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param use_stub_resolver
# Takes a boolean argument. When "false" (default) it uses /var/run/systemd/resolve/resolv.conf
# as /etc/resolv.conf. When "true", it uses /var/run/systemd/resolve/stub-resolv.conf
# @param manage_networkd
# Manage the systemd network daemon
#
Expand Down Expand Up @@ -74,6 +77,7 @@
Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec,
Boolean $cache,
Optional[Variant[Boolean,Enum['udp','tcp']]] $dns_stub_listener,
Boolean $use_stub_resolver,
Boolean $manage_networkd,
Enum['stopped','running'] $networkd_ensure,
Boolean $manage_timesyncd,
Expand Down
11 changes: 10 additions & 1 deletion manifests/resolved.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
# @param dns_stub_listener
# Takes a boolean argument or one of "udp" and "tcp".
#
# @param use_stub_resolver
# Takes a boolean argument. When "false" (default) it uses /var/run/systemd/resolve/resolv.conf
# as /etc/resolv.conf. When "true", it uses /var/run/systemd/resolve/stub-resolv.conf
#
class systemd::resolved (
Enum['stopped','running'] $ensure = $systemd::resolved_ensure,
Optional[Variant[Array[String],String]] $dns = $systemd::dns,
Expand All @@ -47,6 +51,7 @@
Optional[Variant[Boolean,Enum['allow-downgrade']]] $dnssec = $systemd::dnssec,
Boolean $cache = $systemd::cache,
Optional[Variant[Boolean,Enum['udp', 'tcp']]] $dns_stub_listener = $systemd::dns_stub_listener,
Boolean $use_stub_resolver = $systemd::use_stub_resolver,
){

assert_private()
Expand All @@ -62,9 +67,13 @@
enable => $_enable_resolved,
}

$_resolv_conf_target = $use_stub_resolver ? {
true => '/run/systemd/resolve/stub-resolv.conf',
default => '/run/systemd/resolve/resolv.conf',
}
file { '/etc/resolv.conf':
ensure => 'symlink',
target => '/run/systemd/resolve/resolv.conf',
target => $_resolv_conf_target,
require => Service['systemd-resolved'],
}

Expand Down

0 comments on commit d1c2ec3

Please sign in to comment.