forked from osism/ansible-collection-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_compose.py
76 lines (54 loc) · 1.91 KB
/
docker_compose.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
import pytest
from .util.util import get_ansible, get_variable
testinfra_runner, testinfra_hosts = get_ansible()
def test_var(host):
assert get_variable(host, "docker_compose_install_type") == "package"
def test_systemd(host):
f = host.file("/etc/systemd/system/[email protected]")
assert f.exists
assert f.is_file
assert f.user == "root"
assert f.group == "root"
assert f.mode == 0o644
service_user = get_variable(host, "docker_compose_service_user")
assert f"User={service_user}" in f.content_string
def test_osism_target(host):
f = host.file("/etc/systemd/system/osism.target")
assert f.exists
assert f.is_file
assert f.mode == 0o644
assert host.service("osism.target").is_enabled
assert (
"OSISM target allowing to start/stop all OSISM service at once"
in f.content_string
)
def test_apt_preference(host):
f = host.file("/etc/apt/preferences.d/docker-compose")
assert not f.exists
def test_pkg(host):
# We do NOT want the compose package
package_name = get_variable(host, "docker_compose_package_name")
assert package_name != ""
package = host.package(package_name)
assert not package.is_installed
# We want to have the plugin package
package_name = get_variable(host, "docker_compose_plugin_package_name")
assert package_name != ""
package = host.package(package_name)
assert package.is_installed
def test_wrapper_file(host):
f = host.file("/usr/local/bin/docker-compose")
if not f.exists:
pytest.skip("Wrapper file does not exist.")
assert f.exists
assert f.is_file
assert f.mode == 0o755
assert (
f.content_string.strip()
== """#!/usr/bin/env bash
# The docker-compose CLI has been removed in OSISM.
# The Compose plugin for Docker is now used.
# The plugin can be called via 'docker compose'.
/usr/bin/docker compose "$@"
""".strip()
)