forked from osism/ansible-collection-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer.py
104 lines (76 loc) · 3.21 KB
/
container.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import pytest
from ..util.util import get_ansible, get_variable
testinfra_runner, testinfra_hosts = get_ansible()
def check_cephclient_install_type(host):
if get_variable(host, "cephclient_install_type") != "container":
pytest.skip("cephclient_install_type mismatch")
def test_dirs(host):
check_cephclient_install_type(host)
directories = [
get_variable(host, "cephclient_configuration_directory"),
get_variable(host, "cephclient_data_directory"),
get_variable(host, "cephclient_docker_compose_directory"),
]
for d in directories:
f = host.file(d)
assert f.exists
assert f.is_directory
assert f.mode == 0o750
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
def test_configfile(host):
check_cephclient_install_type(host)
f = host.file(
f"{get_variable(host, 'cephclient_configuration_directory')}/ceph.conf"
)
assert f.exists
assert not f.is_directory
assert f.mode == 0o640
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
with host.sudo(get_variable(host, "operator_user")):
assert "[global]" in f.content_string
def test_keyringfile(host):
check_cephclient_install_type(host)
cephclient_keyring_name = get_variable(host, "cephclient_keyring_name")
f = host.file(
f"{get_variable(host, 'cephclient_configuration_directory')}/ceph.{cephclient_keyring_name}.keyring"
)
assert f.exists
assert not f.is_directory
assert f.mode == 0o640
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
cephclient_keyring = get_variable(host, "cephclient_keyring")
with host.sudo(get_variable(host, "operator_user")):
assert cephclient_keyring in f.content_string
def test_dockercompose(host):
check_cephclient_install_type(host)
f = host.file(
f"{get_variable(host, 'cephclient_docker_compose_directory')}/docker-compose.yml"
)
assert f.exists
assert not f.is_directory
assert f.mode == 0o640
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
cephclient_container_name = get_variable(host, "cephclient_container_name")
with host.sudo(get_variable(host, "operator_user")):
assert f'container_name: "{cephclient_container_name}' in f.content_string
def test_srv(host):
check_cephclient_install_type(host)
cephclient_service_name = get_variable(host, "cephclient_service_name")
service = host.service(cephclient_service_name)
assert service.is_enabled
assert service.is_running
def test_wrapper(host):
check_cephclient_install_type(host)
items = ["ceph", "ceph-authtool", "crushtool", "rados", "radosgw-admin", "rbd"]
for item in items:
f = host.file(f"/usr/local/bin/{item}")
assert f.exists
assert not f.is_directory
assert f.mode == 0o755
assert f.user == get_variable(host, "operator_user")
assert f.group == get_variable(host, "operator_group")
assert "docker exec" in f.content_string