Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 69 additions & 3 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

### Defined types

* [`powerdns::config`](#powerdns--config): Manage powerdns settings
* [`powerdns::config`](#powerdns--config): Manage powerdns settings in old format, see https://doc.powerdns.com/recursor/settings.html
Supported up to recursor version 5.2.

### Resource types

Expand Down Expand Up @@ -107,6 +108,12 @@ The following parameters are available in the `powerdns` class:
* [`authoritative_group`](#-powerdns--authoritative_group)
* [`authoritative_file_owner`](#-powerdns--authoritative_file_owner)
* [`authoritative_file_group`](#-powerdns--authoritative_file_group)
* [`recursor_use_yaml`](#-powerdns--recursor_use_yaml)
* [`recursor_config_includedir`](#-powerdns--recursor_config_includedir)
* [`recursor_forward_zones_file`](#-powerdns--recursor_forward_zones_file)
* [`recursor_local_config_file`](#-powerdns--recursor_local_config_file)
* [`recursor_local_config`](#-powerdns--recursor_local_config)
* [`recursor_forward_zones`](#-powerdns--recursor_forward_zones)

##### <a name="-powerdns--authoritative_package_name"></a>`authoritative_package_name`

Expand Down Expand Up @@ -152,7 +159,7 @@ Authoritative config file path

##### <a name="-powerdns--authoritative_version"></a>`authoritative_version`

Data type: `Pattern[/4\.[0-9]+/]`
Data type: `Pattern[/[4,5]\.[0-9]+/]`

Authoritative server version

Expand Down Expand Up @@ -545,6 +552,54 @@ Group of authoritative config files

Default value: `$authoritative_group`

##### <a name="-powerdns--recursor_use_yaml"></a>`recursor_use_yaml`

Data type: `Boolean`



Default value: `false`

##### <a name="-powerdns--recursor_config_includedir"></a>`recursor_config_includedir`

Data type: `Optional[Stdlib::Absolutepath]`



Default value: `undef`

##### <a name="-powerdns--recursor_forward_zones_file"></a>`recursor_forward_zones_file`

Data type: `Optional[Stdlib::Absolutepath]`



Default value: `undef`

##### <a name="-powerdns--recursor_local_config_file"></a>`recursor_local_config_file`

Data type: `Optional[Stdlib::Absolutepath]`



Default value: `undef`

##### <a name="-powerdns--recursor_local_config"></a>`recursor_local_config`

Data type: `Optional[Hash]`



Default value: `undef`

##### <a name="-powerdns--recursor_forward_zones"></a>`recursor_forward_zones`

Data type: `Optional[Tuple]`



Default value: `undef`

### <a name="powerdns--authoritative"></a>`powerdns::authoritative`

powerdns::authoritative
Expand Down Expand Up @@ -582,6 +637,7 @@ powerdns recursor
The following parameters are available in the `powerdns::recursor` class:

* [`forward_zones`](#-powerdns--recursor--forward_zones)
* [`config`](#-powerdns--recursor--config)

##### <a name="-powerdns--recursor--forward_zones"></a>`forward_zones`

Expand All @@ -591,6 +647,15 @@ Hash containing zone => dns servers pairs

Default value: `$powerdns::forward_zones`

##### <a name="-powerdns--recursor--config"></a>`config`

Data type: `Hash`

recursor config (will be converted to YAML, see https://doc.powerdns.com/recursor/yamlsettings.html)
when powerdns::recursor_use_yaml is set to `true`

Default value: `{}`

### <a name="powerdns--repo"></a>`powerdns::repo`

powerdns::repo
Expand All @@ -599,7 +664,8 @@ powerdns::repo

### <a name="powerdns--config"></a>`powerdns::config`

Manage powerdns settings
Manage powerdns settings in old format, see https://doc.powerdns.com/recursor/settings.html
Supported up to recursor version 5.2.

#### Parameters

Expand Down
8 changes: 6 additions & 2 deletions data/common.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
---
lookup_options:
powerdns::recursor_local_config:
merge: deep
powerdns::authoritative_package_ensure: installed
powerdns::authoritative_extra_packages_ensure: installed
powerdns::authoritative_version: '4.9'
powerdns::authoritative_version: "4.9"
powerdns::recursor_package_ensure: installed
powerdns::recursor_version: '5.0'
powerdns::recursor_version: "5.0"
powerdns::recursor_user: pdns
powerdns::recursor_group: pdns
powerdns::recursor_file_owner: root
powerdns::recursor_file_group: "%{lookup('powerdns::recursor_group')}"
powerdns::recursor_use_yaml: false
9 changes: 9 additions & 0 deletions data/os/Debian/12.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
powerdns::mysql_charset: utf8mb3
powerdns::mysql_collate: utf8mb3_general_ci
powerdns::authoritative_version: "5.0"
powerdns::recursor_version: "5.3"
powerdns::recursor_use_yaml: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we make the decision based on the recursor_version?

Note

Starting with version 5.0.0, Recursor supports a new YAML syntax for configuration files as described here. If both recursor.conf and recursor.yml files are found in the configuration directory the YAML file is used. A configuration using the old style syntax can be converted to a YAML configuration using the instructions in [Conversion of old-style settings to YAML format](https://doc.powerdns.com/recursor/appendices/yamlconversion.html).

Release 5.0.0 will install a default old-style recursor.conf file.

Starting with version 5.1.0, in the absence of a recursor.yml file, an existing recursor.conf will be processed as YAML, if that fails, it will be processed as old-style configuration. Packages will stop installing a old-style recursor.conf file and start installing a default recursor.conf file containing YAML syntax.

With the release of 5.2.0, the default will be to expect a YAML configuration file and reading of old-style recursor.conf files will have to be enabled specifically by providing a command line option --enable-old-settings.

In a future release support for the “old-style” recursor.conf settings file will be dropped.

source: https://doc.powerdns.com/recursor/yamlsettings.html

Copy link
Contributor Author

@deric deric Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saz Yeah, you're right. There are no earlier packages for Debian 13. For Debian 12 we shouldn't set the version (any recursor version between 4.8 to 5.3 is supported). See https://repo.powerdns.com/debian/dists/

powerdns::recursor_config_includedir: "%{lookup('powerdns::recursor_configdir')}/recursor.d"
powerdns::recursor_forward_zones_file: "%{lookup('powerdns::recursor_configdir')}/forward-zones.yml"
powerdns::recursor_local_config_file: "%{lookup('powerdns::recursor_config_includedir')}/00-local.yml"
9 changes: 9 additions & 0 deletions data/os/Debian/13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
powerdns::mysql_charset: utf8
powerdns::mysql_collate: utf8_general_ci
powerdns::authoritative_version: "5.0"
powerdns::recursor_version: "5.3"
powerdns::recursor_use_yaml: true
powerdns::recursor_config_includedir: "%{lookup('powerdns::recursor_configdir')}/recursor.d"
powerdns::recursor_forward_zones_file: "%{lookup('powerdns::recursor_configdir')}/forward-zones.yml"
powerdns::recursor_local_config_file: "%{lookup('powerdns::recursor_config_includedir')}/00-local.yml"
7 changes: 7 additions & 0 deletions data/os/Ubuntu/22.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
powerdns::authoritative_version: "5.0"
powerdns::recursor_version: "5.3"
powerdns::recursor_use_yaml: true
powerdns::recursor_config_includedir: "%{lookup('powerdns::recursor_configdir')}/recursor.d"
powerdns::recursor_forward_zones_file: "%{lookup('powerdns::recursor_configdir')}/forward-zones.yml"
powerdns::recursor_local_config_file: "%{lookup('powerdns::recursor_config_includedir')}/00-local.yml"
7 changes: 7 additions & 0 deletions data/os/Ubuntu/24.04.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
powerdns::authoritative_version: "5.0"
powerdns::recursor_version: "5.3"
powerdns::recursor_use_yaml: true
powerdns::recursor_config_includedir: "%{lookup('powerdns::recursor_configdir')}/recursor.d"
powerdns::recursor_forward_zones_file: "%{lookup('powerdns::recursor_configdir')}/forward-zones.yml"
powerdns::recursor_local_config_file: "%{lookup('powerdns::recursor_config_includedir')}/00-local.yml"
3 changes: 2 additions & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# @summary Manage powerdns settings
# @summary Manage powerdns settings in old format, see https://doc.powerdns.com/recursor/settings.html
# Supported up to recursor version 5.2.
#
# @param setting
# The setting you want to change
Expand Down
12 changes: 10 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
String[1] $authoritative_service_name,
Stdlib::Absolutepath $authoritative_configdir,
Stdlib::Absolutepath $authoritative_config,
Pattern[/4\.[0-9]+/] $authoritative_version,
Pattern[/[4,5]\.[0-9]+/] $authoritative_version,
Stdlib::Absolutepath $db_file,
Stdlib::Absolutepath $mysql_schema_file,
Stdlib::Absolutepath $pgsql_schema_file,
Expand All @@ -157,6 +157,12 @@
Optional[String[1]] $mysql_collate = undef,
Boolean $authoritative = true,
Boolean $recursor = false,
Boolean $recursor_use_yaml = false,
Optional[Stdlib::Absolutepath] $recursor_config_includedir = undef,
Optional[Stdlib::Absolutepath] $recursor_forward_zones_file = undef,
Optional[Stdlib::Absolutepath] $recursor_local_config_file = undef,
Optional[Hash] $recursor_local_config = undef,
Optional[Tuple] $recursor_forward_zones = undef,
Powerdns::Backends $backend = 'mysql',
Boolean $backend_install = true,
Boolean $backend_create_tables = true,
Expand Down Expand Up @@ -226,7 +232,9 @@
# Set up Hiera for the recursor.
$powerdns_recursor_config = lookup('powerdns::recursor::config', Hash, 'deep', {})
$powerdns_recursor_defaults = { 'type' => 'recursor' }
create_resources(powerdns::config, $powerdns_recursor_config, $powerdns_recursor_defaults)
if !($recursor_use_yaml) {
create_resources(powerdns::config, $powerdns_recursor_config, $powerdns_recursor_defaults)
}
}

if $purge_autoprimaries {
Expand Down
80 changes: 66 additions & 14 deletions manifests/recursor.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,89 @@
#
# @param forward_zones
# Hash containing zone => dns servers pairs
# @param config recursor config (will be converted to YAML, see https://doc.powerdns.com/recursor/yamlsettings.html)
# when powerdns::recursor_use_yaml is set to `true`
#
class powerdns::recursor (
Hash $forward_zones = $powerdns::forward_zones,
Hash $config = {},
) inherits powerdns {
package { $powerdns::recursor_package_name:
ensure => $powerdns::recursor_package_ensure,
}

file { $powerdns::recursor_config:
ensure => file,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
require => Package[$powerdns::recursor_package_name],
}
if $powerdns::recursor_use_yaml {
## Use New YAML based configuration
$forward_block = empty($powerdns::recursor_forward_zones) ? {
true => {},
false => { 'forward_zones_file' => $powerdns::recursor_forward_zones_file },
}

$recursor_config = {
'recursor' => {
'include_dir' => $powerdns::recursor_config_includedir,
} + $forward_block + $config,
}

if !empty($powerdns::recursor_forward_zones) {
file { $powerdns::recursor_forward_zones_file:
ensure => file,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
content => stdlib::to_yaml($powerdns::recursor_forward_zones),
notify => Service['pdns-recursor'],
}
}
file { $powerdns::recursor_config_includedir:
ensure => directory,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
require => Package[$powerdns::recursor_package_name],
}

if !empty($forward_zones) {
$zone_config = "${powerdns::recursor_configdir}/forward_zones.conf"
file { $zone_config:
file { $powerdns::recursor_config:
ensure => file,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
content => template('powerdns/forward_zones.conf.erb'),
content => stdlib::to_yaml($recursor_config),
require => Package[$powerdns::recursor_package_name],
notify => Service['pdns-recursor'],
}

powerdns::config { 'forward-zones-file':
value => $zone_config,
type => 'recursor',
file { $powerdns::recursor_local_config_file:
ensure => file,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
content => stdlib::to_yaml(lookup('powerdns::recursor_local_config', Data, 'deep', {})),
require => Package[$powerdns::recursor_package_name],
notify => Service['pdns-recursor'],
}
}
} else {
## Use Old INI based configuration

file { $powerdns::recursor_config:
ensure => file,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
require => Package[$powerdns::recursor_package_name],
}

if !empty($forward_zones) {
$zone_config = "${powerdns::recursor_configdir}/forward_zones.conf"
file { $zone_config:
ensure => file,
owner => $powerdns::recursor_file_owner,
group => $powerdns::recursor_file_group,
content => template('powerdns/forward_zones.conf.erb'),
notify => Service['pdns-recursor'],
}

powerdns::config { 'forward-zones-file':
value => $zone_config,
type => 'recursor',
}
}
}
service { 'pdns-recursor':
ensure => running,
name => $powerdns::recursor_service_name,
Expand Down
1 change: 1 addition & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"22.04",
"24.04"
]
},
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/class_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class { 'powerdns':
end

describe command('/usr/bin/pdns_control version') do
its(:stdout) { is_expected.to match %r{^4\.9} }
its(:stdout) { is_expected.to match %r{^(4\.9|5\.\d)} }
end
end

Expand Down
Loading