Skip to content

Commit c2bc9c6

Browse files
authored
Add role-level package state controls for PowerDNS, debug symbols, ba… (#261)
* Add role-level package state controls for PowerDNS, debug symbols, backend packages, and backend dependency packages
1 parent 85967ff commit c2bc9c6

File tree

22 files changed

+558
-315
lines changed

22 files changed

+558
-315
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## v1.10.0 (Unreleased)
2+
3+
NEW FEATURES:
4+
- Add role-level package state controls for PowerDNS, debug symbols, backend packages, and backend dependency packages:
5+
`pdns_package_state`, `pdns_debug_symbols_package_state`, `pdns_backends_packages_state`,
6+
`pdns_mysql_packages_state`, `pdns_pgsql_packages_state`, and `pdns_sqlite_package_state`.
7+
- Add role documentation section describing standard tags (`install`, `config`, `service`, `repository`).
8+
9+
IMPROVEMENTS:
10+
- Add explicit task/handler tags across installation, repository, configuration, and service flows to support predictable partial runs.
11+
- Refactor MySQL, PostgreSQL, and SQLite database tasks into clearer management blocks with explicit package-state handling.
12+
- Improve role behavior when `pdns_package_state: absent` by skipping runtime configuration/service tasks while still allowing dependency/package removal paths.
13+
- Normalize defaults/documentation booleans (`true`/`false`) and fix minor typos.
14+
- Include `hostname` in the EL Molecule Docker image package set.
15+
116
## v1.9.0 (2026-02-23)
217

318
NEW FEATURES:

README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ If `apt_version` is omitted, the legacy `apt_repo` string is used with `ansible.
8383
```
8484

8585
By default, install EPEL to satisfy some PowerDNS Authoritative Server dependencies like `protobuf`.
86-
To skip the installation of EPEL set `pdns_install_epel` to `False`.
86+
To skip the installation of EPEL set `pdns_install_epel` to `false`.
8787

8888
```yaml
8989
pdns_package_name: "{{ default_pdns_package_name }}"
@@ -97,6 +97,13 @@ pdns_package_version: ""
9797

9898
Optionally, allow to set a specific version of the PowerDNS Authoritative Server package to be installed.
9999

100+
```yaml
101+
pdns_package_state: "present"
102+
```
103+
104+
Desired package state for `pdns_package_name`. Supported values include `present`, `latest`, and `absent`.
105+
When set to `absent`, the role removes packages and skips runtime configuration tasks.
106+
100107
```yaml
101108
pdns_install_debug_symbols_package: false
102109
```
@@ -107,9 +114,15 @@ Install the PowerDNS Authoritative Server debug symbols.
107114
pdns_debug_symbols_package_name: "{{ default_pdns_debug_symbols_package_name }}"
108115
```
109116

110-
The name of the PowerDNS Authoritative Server debug package to be installed when `pdns_install_debug_symbols_package` is `True`,
117+
The name of the PowerDNS Authoritative Server debug package to be installed when `pdns_install_debug_symbols_package` is `true`,
111118
`pdns-debuginfo` on RedHat-like systems and `pdns-server-dbg` on Debian-like systems.
112119

120+
```yaml
121+
pdns_debug_symbols_package_state: "{{ pdns_package_state }}"
122+
```
123+
124+
Desired package state for the debug symbols package when it is managed by this role.
125+
113126
```yaml
114127
pdns_user: pdns
115128
pdns_group: pdns
@@ -129,7 +142,7 @@ Name of the PowerDNS service.
129142

130143
```yaml
131144
pdns_service_state: "started"
132-
pdns_service_enabled: "yes"
145+
pdns_service_enabled: true
133146
pdns_service_masked: false
134147
```
135148

@@ -185,6 +198,7 @@ This can be used to change any systemd settings in the `[Service]` category.
185198

186199
```yaml
187200
pdns_backends_packages: "{{ default_pdns_backends_packages }}"
201+
pdns_backends_packages_state: "{{ pdns_package_state }}"
188202
pdns_backends:
189203
bind:
190204
config: '/dev/null'
@@ -208,11 +222,12 @@ pdns_backends:
208222
'dbname': dns
209223
'bind':
210224
'config': '/etc/named/named.conf'
211-
'hybrid': yes
225+
'hybrid': true
212226
'dnssec-db': '{{ pdns_config_dir }}/dnssec.db'
213227
```
214228

215229
By default this role starts just the bind-backend with an empty config file.
230+
`pdns_backends_packages_state` controls install/update/removal of backend packages.
216231

217232
```yaml
218233
pdns_config_additional_dirs: []
@@ -263,6 +278,7 @@ pdns_mysql_cli_extra_args: "{{ default_pdns_mysql_cli_extra_args }}"
263278
pdns_mysql_auth_plugin: ""
264279
pdns_mysql_user_update_password: ""
265280
pdns_mysql_packages: "{{ default_pdns_mysql_packages }}"
281+
pdns_mysql_packages_state: "present"
266282
```
267283
268284
`pdns_mysql_manage_database` controls whether this role performs MySQL/MariaDB bootstrap operations
@@ -295,11 +311,13 @@ When `pdns_mysql_query_use_socket` is set to `true`, role-internal MySQL operati
295311
`pdns_mysql_unix_socket` instead of TCP host/port.
296312
`pdns_backends_mysql_cmd` and `pdns_mysql_cli_extra_args` control the MySQL/MariaDB CLI invocation used for schema checks/import.
297313
`pdns_mysql_packages` allows overriding OS-specific MySQL dependency package lists.
314+
`pdns_mysql_packages_state` controls install/update/removal of those dependency packages.
298315

299316
```yaml
300317
pdns_pgsql_manage_database: true
301318
pdns_pgsql_databases_credentials: {}
302319
pdns_pgsql_packages: "{{ default_pdns_pgsql_packages }}"
320+
pdns_pgsql_packages_state: "present"
303321
```
304322

305323
`pdns_pgsql_manage_database` controls whether this role performs PostgreSQL bootstrap operations
@@ -328,6 +346,7 @@ When `pdns_pgsql_query_use_socket` is set to `true`, role-internal PostgreSQL op
328346
(database/user creation and schema load checks/import) use the UNIX socket path defined by
329347
`pdns_pgsql_unix_socket` instead of TCP host/port.
330348
`pdns_pgsql_packages` allows overriding OS-specific PostgreSQL dependency package lists.
349+
`pdns_pgsql_packages_state` controls install/update/removal of those dependency packages.
331350

332351
```yaml
333352
pdns_sqlite_databases_locations: []
@@ -336,6 +355,12 @@ pdns_sqlite_databases_locations: []
336355
Locations of the SQLite3 databases that have to be created if using the
337356
`gsqlite3` backend.
338357

358+
```yaml
359+
pdns_sqlite_package_state: "present"
360+
```
361+
362+
Desired package state for the SQLite CLI dependency used during schema bootstrap.
363+
339364
```yaml
340365
pdns_lmdb_databases_locations: []
341366
```
@@ -371,6 +396,18 @@ pdns_verbose: "{{ ansible_verbosity | int >= 2 }}"
371396
Enable verbose/debug role behavior. This currently controls whether sensitive SQL task details
372397
are hidden in logs (`false`) or visible for troubleshooting (`true`).
373398

399+
## Role Tags
400+
401+
This role uses the following standard tags so filtered runs stay predictable with `--tags` / `--skip-tags`:
402+
403+
- `install`: package/module installation or software provisioning.
404+
- `config`: configuration/state changes (templates, files, directories, settings, data bootstrap).
405+
- `service`: service state management and service-related handlers.
406+
- `repository`: repository/key/pinning setup and repository cache refresh.
407+
408+
Some prerequisite tasks intentionally have multiple tags (for example `install` + `repository`,
409+
or `install` + `config`) so filtered runs include the dependencies required by the selected path.
410+
374411
## Example Playbooks
375412

376413
Run as a primary using the bind backend (when you already have a `named.conf` file):

defaults/main.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ pdns_package_name: "{{ default_pdns_package_name }}"
5959
# where each YUM repository can contains multiple versions of the same package.
6060
pdns_package_version: ""
6161

62+
# Desired state of the PowerDNS Authoritative Server package.
63+
# Supported values include present, latest and absent.
64+
pdns_package_state: "present"
65+
6266
# Install the PowerDNS Authoritative Server debug symbols package
6367
pdns_install_debug_symbols_package: false
6468

6569
# The name of the PowerDNS Authoritative Server debug symbols package
6670
pdns_debug_symbols_package_name: "{{ default_pdns_debug_symbols_package_name }}"
6771

72+
# Desired state of the debug symbols package when managed by this role.
73+
# Supported values include present, latest and absent.
74+
pdns_debug_symbols_package_state: "{{ pdns_package_state }}"
75+
6876
# The user and group the PowerDNS Authoritative Server process will run as.
6977
# NOTE: at the moment, we don't create a user as we assume the package creates
7078
# a "pdns" user and group. If you change these variables, make sure to create
@@ -79,7 +87,7 @@ pdns_service_name: "pdns"
7987

8088
# State of the PowerDNS Authoritative Server service
8189
pdns_service_state: "started"
82-
pdns_service_enabled: "yes"
90+
pdns_service_enabled: true
8391
pdns_service_masked: false
8492

8593
# When True, disable the automated restart of the PowerDNS service
@@ -92,7 +100,7 @@ pdns_manage_selinux: true
92100
pdns_config_dir: "{{ default_pdns_config_dir }}"
93101
pdns_config_file: "pdns.conf"
94102

95-
# Ddict containing all configuration options, except for backend
103+
# Dict containing all configuration options, except for backend
96104
# configuration and the "config-dir", "setuid" and "setgid" directives.
97105
pdns_config: {}
98106
# pdns_config:
@@ -111,6 +119,10 @@ pdns_service_overrides: "{{ default_pdns_service_overrides }}"
111119
# backendname: packagename
112120
pdns_backends_packages: "{{ default_pdns_backends_packages }}"
113121

122+
# Desired state of backend packages.
123+
# Supported values include present, latest and absent.
124+
pdns_backends_packages_state: "{{ pdns_package_state }}"
125+
114126
# A dict with all the backends you'd like to configure.
115127
# This default starts just the bind-backend with an empty config file
116128
pdns_backends:
@@ -130,7 +142,7 @@ pdns_backends:
130142
# 'dbname': dns
131143
# 'bind':
132144
# 'config': '/etc/named/named.conf'
133-
# 'hybrid': yes
145+
# 'hybrid': true
134146
# 'check-interval': 60
135147
# 'dnssec-db': '{{ pdns_config_dir }}/dnssec.db'
136148

@@ -193,6 +205,10 @@ pdns_mysql_query_use_socket: false
193205
# By default, OS-specific vars files provide the actual package list.
194206
pdns_mysql_packages: "{{ default_pdns_mysql_packages }}"
195207

208+
# Desired state of MySQL dependency packages.
209+
# Supported values include present, latest and absent.
210+
pdns_mysql_packages_state: "{{ pdns_package_state }}"
211+
196212
# UNIX socket path used when pdns_mysql_query_use_socket is true.
197213
pdns_mysql_unix_socket: "/var/run/mysqld/mysqld.sock"
198214

@@ -232,18 +248,26 @@ pdns_pgsql_query_use_socket: false
232248
# By default, OS-specific vars files provide the actual package list.
233249
pdns_pgsql_packages: "{{ default_pdns_pgsql_packages }}"
234250

251+
# Desired state of PostgreSQL dependency packages.
252+
# Supported values include present, latest and absent.
253+
pdns_pgsql_packages_state: "{{ pdns_package_state }}"
254+
235255
# UNIX socket path used when pdns_pgsql_query_use_socket is true.
236256
pdns_pgsql_unix_socket: "/var/run/postgresql"
237257

238258
# This will create the PowerDNS Authoritative Server backend SQLite database
239259
# in the given locations.
240-
# NOTE: Requries the SQLite CLI tools to be available in the machine and the gsqlite3
260+
# NOTE: Requires the SQLite CLI tools to be available in the machine and the gsqlite3
241261
# backend to be installed on the machine.
242262
pdns_sqlite_databases_locations: []
243263

264+
# Desired state of the SQLite CLI dependency package.
265+
# Supported values include present, latest and absent.
266+
pdns_sqlite_package_state: "{{ pdns_package_state }}"
267+
244268
# This will create the PowerDNS Authoritative Server backend LMDB database
245269
# in the given locations.
246-
# NOTE: Requries lmdb backend to be installed on the machine.
270+
# NOTE: Requires lmdb backend to be installed on the machine.
247271
pdns_lmdb_databases_locations: []
248272

249273
# By default, we'll load the MySQL default schema. Set this to false to disable loading the schema

handlers/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
daemon_reload: true
55
listen: reload systemd
66
when: not pdns_disable_handlers
7+
tags:
8+
- service
79

810
- name: Restart PowerDNS
911
ansible.builtin.systemd:
@@ -13,8 +15,13 @@
1315
when:
1416
- not pdns_disable_handlers
1517
- pdns_service_state != 'stopped'
18+
tags:
19+
- service
1620

1721
- name: Update the apt cache
1822
ansible.builtin.apt:
1923
update_cache: true
2024
listen: update the apt cache
25+
tags:
26+
- install
27+
- repository

molecule/pdns-48/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ provisioner:
9696
ssh_connection:
9797
pipelining: true
9898
playbooks:
99+
# cleanup: ../resources/cleanup.yml
99100
create: ../resources/create.yml
100101
destroy: ../resources/destroy.yml
101102
prepare: ../resources/prepare.yml

molecule/pdns-49/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ provisioner:
107107
ssh_connection:
108108
pipelining: true
109109
playbooks:
110+
# cleanup: ../resources/cleanup.yml
110111
create: ../resources/create.yml
111112
destroy: ../resources/destroy.yml
112113
prepare: ../resources/prepare.yml

molecule/pdns-50/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ provisioner:
116116
ssh_connection:
117117
pipelining: true
118118
playbooks:
119+
# cleanup: ../resources/cleanup.yml
119120
create: ../resources/create.yml
120121
destroy: ../resources/destroy.yml
121122
prepare: ../resources/prepare.yml

molecule/pdns-master/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ provisioner:
102102
ssh_connection:
103103
pipelining: true
104104
playbooks:
105+
# cleanup: ../resources/cleanup.yml
105106
create: ../resources/create.yml
106107
destroy: ../resources/destroy.yml
107108
prepare: ../resources/prepare.yml

molecule/pdns-os-repos/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ provisioner:
5656
ssh_connection:
5757
pipelining: true
5858
playbooks:
59+
# cleanup: ../resources/cleanup.yml
5960
create: ../resources/create.yml
6061
destroy: ../resources/destroy.yml
6162
prepare: ../resources/prepare.yml

molecule/resources/Dockerfile.el-systemd.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM {{ item.image }}
55
ENV container docker
66

77
RUN dnf makecache && \
8-
dnf install -y systemd python3 python3-pip sudo bash vim iproute procps-ng && \
8+
dnf install -y systemd python3 python3-pip sudo bash vim iproute procps-ng hostname && \
99
rm -Rf /usr/share/doc && \
1010
rm -Rf /usr/share/man && \
1111
dnf clean all

0 commit comments

Comments
 (0)