forked from osism/ansible-collection-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.py
32 lines (23 loc) · 957 Bytes
/
state.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from .util.util import get_ansible, get_variable
testinfra_runner, testinfra_hosts = get_ansible()
def test_custom_facts_directory(host):
custom_facts_dir = "/etc/ansible/facts.d"
file = host.file(custom_facts_dir)
assert file.exists
assert file.is_directory
assert file.user == "root"
assert file.group == "root"
assert file.mode == 0o755
def test_state_file(host):
state_name = get_variable(host, "state_name")
state_section = get_variable(host, "state_section")
state_option = get_variable(host, "state_option")
state_value = get_variable(host, "state_value")
state_file_path = f"/etc/ansible/facts.d/{state_name}.fact"
file = host.file(state_file_path)
assert file.exists
assert file.user == "root"
assert file.group == "root"
assert file.mode == 0o644
assert f"[{state_section}]" in file.content_string
assert f"{state_option} = {state_value}" in file.content_string