Service¶
Manage systemd units on the target. The target must run systemd, and the connection user must have permission to manage the requested service. See Quickstart for rendering a unit and checking a running service.
- class rmote.tools.service.Service[source]¶
Bases:
ToolManage systemd services on the remote host. Requires systemd and root.
Every operation runs
systemctl. A target without it refuses with NotImplementedError, which names systemd as what provides it.Start and enable a real systemd unit in a disposable Debian container:
>>> from rmote.tools import Exec, FileSystem >>> remote = getfixture("debian_tool") >>> unit = "[Service]\nExecStart=/bin/sleep infinity\n[Install]\nWantedBy=multi-user.target\n" >>> remote(FileSystem.write, "/etc/systemd/system/example.service", unit) True >>> _ = remote(Exec.command, "systemctl", "daemon-reload") >>> result = remote(Service.converge, "example.service", started=True, enabled=True) >>> result.started, result.enabled, result.changed (True, True, True) >>> remote(Service.converge, "example.service", started=True, enabled=True).changed False >>> result = remote(Service.converge, "example.service", started=False, enabled=False) >>> result.started, result.enabled, result.changed (False, False, True) >>> remote(Service.converge, "example.service", started=False, enabled=False).changed False
- async static converge(name, *, started=True, enabled=True)[source]¶
Idempotently ensure a service is in the desired state.
- async static disable(name)[source]¶
Disable a service at boot. No-op if already disabled.
- Return type: