Skip to content

Commit 513d5ee

Browse files
Merge pull request #1371 from t-woerner/dns_over_tls
ipaserver, ipareplica and ipaclient roles: Add DNS over TLS support
2 parents 91d818b + cd440a2 commit 513d5ee

37 files changed

+572
-73
lines changed

roles/ipaclient/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ Variable | Description | Required
202202
`ipaclient_request_cert` | The bool value defines if the certificate for the machine wil be requested. The certificate will be stored in /etc/ipa/nssdb under the nickname "Local IPA host". . `ipaclient_request_cert` defaults to `no`. The option is deprecated and will be removed in a future release. | no
203203
`ipaclient_keytab` | The string value contains the path on the node of a backup host keytab from a previous enrollment. | no
204204
`ipaclient_automount_location` | Automount location | no
205+
`ipaclient_dns_over_tls` | Configure DNS over TLS. Requires FreeIPA version 4.12.5 or later. (bool, default: false) | no
206+
`ipaclient_no_dnssec_validation` | Disable DNSSEC validation for DNS over TLS. This turns off DNSSEC validation for unbound. Ignored if `ipaserver_dns_over_tls` is not enabled. (bool, default: false) | no
205207

206208

207209
Server Variables

roles/ipaclient/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ ipasssd_enable_dns_updates: no
2626
ipasssd_no_krb5_offline_passwords: no
2727
ipasssd_preserve_sssd: no
2828
ipaclient_request_cert: no
29+
ipaclient_dns_over_tls: no
30+
ipaclient_no_dnssec_validation: no
2931

3032
### packages ###
3133
ipaclient_install_packages: yes

roles/ipaclient/library/ipaclient_setup_nss.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@
8686
type: bool
8787
required: no
8888
default: no
89+
dns_over_tls:
90+
description: Configure DNS over TLS
91+
type: bool
92+
default: no
93+
required: no
94+
no_dnssec_validation:
95+
description: Disable DNSSEC validation for DNS over TLS
96+
type: bool
97+
default: no
98+
required: no
8999
enable_dns_updates:
90100
description: |
91101
Configures the machine to attempt dns updates when the ip address
@@ -212,7 +222,9 @@ def main():
212222
mkhomedir=dict(required=False, type='bool'),
213223
on_master=dict(required=False, type='bool'),
214224
dnsok=dict(required=False, type='bool', default=False),
215-
225+
dns_over_tls=dict(required=False, type='bool', default=False),
226+
no_dnssec_validation=dict(required=False, type='bool',
227+
default=False),
216228
enable_dns_updates=dict(required=False, type='bool'),
217229
all_ip_addresses=dict(required=False, type='bool', default=False),
218230
ip_addresses=dict(required=False, type='list', elements='str',
@@ -249,13 +261,16 @@ def main():
249261
options.mkhomedir = module.params.get('mkhomedir')
250262
options.on_master = module.params.get('on_master')
251263
dnsok = module.params.get('dnsok')
264+
options.dns_over_tls = module.params.get('dns_over_tls')
265+
options.no_dnssec_validation = module.params.get('no_dnssec_validation')
252266

253267
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
254268
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
255269

256270
os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE
257271

258272
options.dns_updates = module.params.get('enable_dns_updates')
273+
options.dns_over_tls = module.params.get('dns_over_tls')
259274
options.all_ip_addresses = module.params.get('all_ip_addresses')
260275
options.ip_addresses = ansible_module_get_parsed_ip_addresses(module)
261276
options.request_cert = module.params.get('request_cert')
@@ -279,7 +294,7 @@ def main():
279294
options.no_sssd = False
280295
options.sssd = not options.no_sssd
281296
options.no_ac = False
282-
options.dns_over_tls = False
297+
options.dns_over_tls = module.params.get('dns_over_tls')
283298
nosssd_files = module.params.get('nosssd_files')
284299
selinux_works = module.params.get('selinux_works')
285300
krb_name = module.params.get('krb_name')

roles/ipaclient/library/ipaclient_setup_sssd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
changes
9292
type: bool
9393
required: no
94+
dns_over_tls:
95+
description: Configure DNS over TLS
96+
type: bool
97+
default: no
98+
required: no
9499
preserve_sssd:
95100
description: Preserve old SSSD configuration if possible
96101
type: bool
@@ -140,6 +145,7 @@ def main():
140145
fixed_primary=dict(required=False, type='bool'),
141146
permit=dict(required=False, type='bool'),
142147
enable_dns_updates=dict(required=False, type='bool'),
148+
dns_over_tls=dict(required=False, type='bool', default=False),
143149
preserve_sssd=dict(required=False, type='bool'),
144150
no_krb5_offline_passwords=dict(required=False, type='bool'),
145151
),
@@ -169,6 +175,7 @@ def main():
169175
options.primary = module.params.get('fixed_primary')
170176
options.permit = module.params.get('permit')
171177
options.dns_updates = module.params.get('enable_dns_updates')
178+
options.dns_over_tls = module.params.get('dns_over_tls')
172179
options.preserve_sssd = module.params.get('preserve_sssd')
173180

174181
options.no_krb5_offline_passwords = module.params.get(

roles/ipaclient/library/ipaclient_test.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@
124124
type: bool
125125
required: no
126126
default: no
127+
dns_over_tls:
128+
description: Configure DNS over TLS
129+
type: bool
130+
default: no
131+
required: no
132+
no_dnssec_validation:
133+
description: Disable DNSSEC validation for DNS over TLS
134+
type: bool
135+
default: no
136+
required: no
127137
enable_dns_updates:
128138
description:
129139
Configures the machine to attempt dns updates when the ip address
@@ -248,7 +258,8 @@
248258
CLIENT_INSTALL_ERROR, tasks, check_ldap_conf, timeconf, constants,
249259
validate_hostname, nssldap_exists, gssapi, remove_file,
250260
check_ip_addresses, ipadiscovery, print_port_conf_info,
251-
IPA_PYTHON_VERSION, getargspec
261+
IPA_PYTHON_VERSION, getargspec, services,
262+
CLIENT_SUPPORTS_NO_DNSSEC_VALIDATION
252263
)
253264

254265

@@ -328,6 +339,9 @@ def main():
328339
default=None),
329340
all_ip_addresses=dict(required=False, type='bool', default=False),
330341
on_master=dict(required=False, type='bool', default=False),
342+
dns_over_tls=dict(required=False, type='bool', default=False),
343+
no_dnssec_validation=dict(required=False, type='bool',
344+
default=False),
331345
# sssd
332346
enable_dns_updates=dict(required=False, type='bool',
333347
default=False),
@@ -356,6 +370,8 @@ def main():
356370
options.ip_addresses = module.params.get('ip_addresses')
357371
options.all_ip_addresses = module.params.get('all_ip_addresses')
358372
options.on_master = module.params.get('on_master')
373+
options.dns_over_tls = module.params.get('dns_over_tls')
374+
options.no_dnssec_validation = module.params.get('no_dnssec_validation')
359375
options.enable_dns_updates = module.params.get('enable_dns_updates')
360376

361377
# Get domain from first server if domain is not set, but if there are
@@ -365,6 +381,16 @@ def main():
365381
options.domain_name = options.servers[0][
366382
options.servers[0].find(".") + 1:]
367383

384+
if options.dns_over_tls \
385+
and not services.knownservices["unbound"].is_installed():
386+
module.fail_json(
387+
msg="To enable DNS over TLS, package ipa-client-encrypted-dns "
388+
"must be installed.")
389+
if options.dns_over_tls and not CLIENT_SUPPORTS_NO_DNSSEC_VALIDATION:
390+
module.fail_json(
391+
msg="Important patches for DNS over TLS are missing in your IPA "
392+
"version.")
393+
368394
try:
369395
self = options
370396

roles/ipaclient/module_utils/ansible_ipa_client.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,15 @@ def configure_nisdomain(_options, domain, _statestore=None):
310310
except ImportError:
311311
configure_selinux_for_client = None
312312

313+
try:
314+
CLIENT_SUPPORTS_NO_DNSSEC_VALIDATION = False
315+
from ipaclient.install.client import ClientInstallInterface
316+
except ImportError:
317+
pass
318+
else:
319+
if hasattr(ClientInstallInterface, "no_dnssec_validation"):
320+
CLIENT_SUPPORTS_NO_DNSSEC_VALIDATION = True
321+
313322
logger = logging.getLogger("ipa-client-install")
314323
root_logger = logger
315324

roles/ipaclient/tasks/install.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
---
22
# tasks file for ipaclient
33

4-
- name: Install - Ensure that IPA client packages are installed
5-
ansible.builtin.package:
6-
name: "{{ ipaclient_packages }}"
7-
state: present
4+
- name: Install - Package installation
85
when: ipaclient_install_packages | bool
6+
block:
7+
8+
- name: Install - Set packages for installation
9+
ansible.builtin.set_fact:
10+
_ipapackages: "{{ ipaclient_packages }}"
11+
12+
- name: Install - Set packages for installlation, add DOT
13+
ansible.builtin.set_fact:
14+
_ipapackages: "{{ _ipapackages + ipaclient_packages_dot }}"
15+
when: ipaclient_dns_over_tls | bool
16+
17+
- name: Install - Ensure that packages are installed
18+
ansible.builtin.package:
19+
name: "{{ _ipapackages }}"
20+
state: present
921

1022
- name: Install - Set ipaclient_servers
1123
ansible.builtin.set_fact:
@@ -38,7 +50,7 @@
3850
msg: "ipaclient_domain or ipaserver_domain is required for ipaclient_configure_dns_resolver"
3951
when: ipaserver_domain is not defined and ipaclient_domain is not defined
4052

41-
- name: Install - Fail on missing ipaclient_servers
53+
- name: Install - Fail on missing ipaclient_dns_servers
4254
ansible.builtin.fail:
4355
msg: "ipaclient_dns_servers is required for ipaclient_configure_dns_resolver"
4456
when: ipaclient_dns_servers is not defined
@@ -69,6 +81,8 @@
6981
ip_addresses: "{{ ipaclient_ip_addresses | default(omit) }}"
7082
all_ip_addresses: "{{ ipaclient_all_ip_addresses }}"
7183
on_master: "{{ ipaclient_on_master }}"
84+
dns_over_tls: "{{ ipaclient_dns_over_tls }}"
85+
no_dnssec_validation: "{{ ipaclient_no_dnssec_validation }}"
7286
### sssd ###
7387
enable_dns_updates: "{{ ipasssd_enable_dns_updates }}"
7488
register: result_ipaclient_test
@@ -323,6 +337,7 @@
323337
fixed_primary: "{{ ipasssd_fixed_primary }}"
324338
permit: "{{ ipasssd_permit }}"
325339
enable_dns_updates: "{{ ipasssd_enable_dns_updates }}"
340+
dns_over_tls: "{{ ipaclient_dns_over_tls }}"
326341
preserve_sssd: "{{ ipasssd_preserve_sssd }}"
327342
no_krb5_offline_passwords: "{{ ipasssd_no_krb5_offline_passwords }}"
328343

@@ -360,6 +375,8 @@
360375
on_master: "{{ ipaclient_on_master }}"
361376
dnsok: "{{ result_ipaclient_test.dnsok }}"
362377
enable_dns_updates: "{{ ipasssd_enable_dns_updates }}"
378+
dns_over_tls: "{{ ipaclient_dns_over_tls }}"
379+
no_dnssec_validation: "{{ ipaclient_no_dnssec_validation }}"
363380
all_ip_addresses: "{{ ipaclient_all_ip_addresses }}"
364381
ip_addresses: "{{ ipaclient_ip_addresses | default(omit) }}"
365382
request_cert: "{{ ipaclient_request_cert }}"

roles/ipaclient/vars/Debian-10.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
# vars/Debian.yml
33
ipaclient_packages: [ "freeipa-client" ]
4+
ipaclient_packages_dot: [ ]
45
# Debian Buster must use python2 as Python interpreter due
56
# to the way freeipa-client package is defined.
67
# You must install package python2.7 before executing this role.

roles/ipaclient/vars/Debian.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# vars/Debian.yml
33
---
44
ipaclient_packages: [ "freeipa-client" ]
5+
ipaclient_packages_dot: [ ]

roles/ipaclient/vars/RedHat-7.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# vars/RedHat-7
33
---
44
ipaclient_packages: [ "ipa-client", "libselinux-python" ]
5+
ipaclient_packages_dot: [ ]

0 commit comments

Comments
 (0)