File tree Expand file tree Collapse file tree 2 files changed +51
-6
lines changed Expand file tree Collapse file tree 2 files changed +51
-6
lines changed Original file line number Diff line number Diff line change 4
4
import os
5
5
6
6
# Third-Party Libraries
7
- import pytest
8
7
import testinfra .utils .ansible_runner
9
8
10
9
testinfra_hosts = testinfra .utils .ansible_runner .AnsibleRunner (
11
10
os .environ ["MOLECULE_INVENTORY_FILE" ]
12
11
).get_hosts ("all" )
13
12
14
13
15
- @pytest .mark .parametrize ("x" , [True ])
16
- def test_packages (host , x ):
17
- """Run a dummy test, just to show what one would look like."""
18
- assert x
14
+ def test_packages (host ):
15
+ """Verify that the expected packages are installed/uninstalled."""
16
+ assert host .package (
17
+ "systemd-resolved"
18
+ ).is_installed , "The package systemd-resolved is not installed."
19
+ assert not host .package (
20
+ "resolvconf"
21
+ ).is_installed , "The package resolvconf is installed."
22
+
23
+
24
+ def test_symlink (host ):
25
+ """Verify that /etc/resolv.conf is the expected symlink."""
26
+ f = host .file ("/etc/resolv.conf" )
27
+ assert f .is_symlink , "/etc/resolv.conf is not a symlink."
28
+ assert (
29
+ f .linked_to == "/run/systemd/resolve/stub-resolv.conf"
30
+ ), "/etc/resolv.conf is not a symlink to /run/systemd/resolve/stub-resolv.conf."
31
+
32
+
33
+ def test_services (host ):
34
+ """Verify that the expected services are present."""
35
+ s = host .service ("systemd-resolved.service" )
36
+ assert s .exists , "systemd-resolved.service does not exist."
37
+ assert s .is_enabled , "systemd-resolved.service is not enabled."
Original file line number Diff line number Diff line change 1
1
---
2
- # tasks file for skeleton
2
+ - name : Install systemd-resolved
3
+ ansible.builtin.package :
4
+ name :
5
+ - systemd-resolved
6
+
7
+ - name : Ensure resolvconf is not installed
8
+ ansible.builtin.package :
9
+ name :
10
+ - resolvconf
11
+ state : absent
12
+
13
+ - name : Create /etc/resolv.conf symlink
14
+ ansible.builtin.file :
15
+ # If a file is already present at /etc/resolv.conf then just
16
+ # delete it.
17
+ force : true
18
+ group : root
19
+ mode : u=rw,g=r,o=r
20
+ owner : root
21
+ path : /etc/resolv.conf
22
+ src : /run/systemd/resolve/stub-resolv.conf
23
+ state : link
24
+
25
+ - name : Enable systemd-resolved
26
+ ansible.builtin.service :
27
+ enabled : true
28
+ name : systemd-resolved.service
You can’t perform that action at this time.
0 commit comments