From 21f1c7d494d72028d32c8d32a8047b35bd43b2e7 Mon Sep 17 00:00:00 2001 From: Antonio Torres Date: Fri, 22 Jul 2022 16:26:30 +0200 Subject: [PATCH] Create systemd-resolved config files for DNS We were writing the server IP directly to resolv.conf in APITest and EnrollmentTest, use systemd-resolved config file instead, as we already do in AuthenticationTest. Signed-off-by: Antonio Torres --- src/ipaperftest/core/constants.py | 49 +++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/src/ipaperftest/core/constants.py b/src/ipaperftest/core/constants.py index 522cfb3..85bcfaf 100644 --- a/src/ipaperftest/core/constants.py +++ b/src/ipaperftest/core/constants.py @@ -242,9 +242,19 @@ def getLevelName(level): - lineinfile: path: /etc/hosts line: '{server_ip} server.{domain} server' - - lineinfile: - path: /etc/resolv.conf - line: nameserver {server_ip} + - file: + path: /etc/systemd/resolved.conf.d + state: directory + - copy: + dest: /etc/systemd/resolved.conf.d/dns.conf + content: | + [Resolve] + DNS={server_ip} + Domains=~. + - systemd: + name: systemd-resolved + state: restarted + daemon-reload: yes - lineinfile: path: /etc/hosts regexp: '127.*.*.*\\s*replica*' @@ -271,6 +281,19 @@ def getLevelName(level): hosts: ipaclients become: yes tasks: + - file: + path: /etc/systemd/resolved.conf.d + state: directory + - copy: + dest: /etc/systemd/resolved.conf.d/dns.conf + content: | + [Resolve] + DNS={server_ip} + Domains=~. + - systemd: + name: systemd-resolved + state: restarted + daemon-reload: yes - lineinfile: path: /etc/resolv.conf regexp: ".*" @@ -307,6 +330,19 @@ def getLevelName(level): hosts: ipaclients become: yes tasks: + - file: + path: /etc/systemd/resolved.conf.d + state: directory + - copy: + dest: /etc/systemd/resolved.conf.d/dns.conf + content: | + [Resolve] + DNS={server_ip} + Domains=~. + - systemd: + name: systemd-resolved + state: restarted + daemon-reload: yes - lineinfile: path: /etc/resolv.conf regexp: ".*" @@ -406,6 +442,13 @@ def getLevelName(level): name: systemd-resolved state: restarted daemon-reload: yes + - lineinfile: + path: /etc/resolv.conf + regexp: ".*" + state: absent + - lineinfile: + path: /etc/resolv.conf + line: nameserver {server_ip} - lineinfile: path: /etc/hosts line: {server_ip} server.{domain} server