Service

class rmote.tools.service.State(*values)[source]

Bases: IntEnum

RELOADED = 3
RESTARTED = 2
STARTED = 0
STOPPED = 1
class rmote.tools.service.Result(name, started, enabled, changed)[source]

Bases: object

changed: bool
enabled: bool
name: str
started: bool
class rmote.tools.service.Service[source]

Bases: Tool

Manage systemd services on the remote host. Requires systemd and root.

static converge(name, *, started=True, enabled=True)[source]

Idempotently ensure a service is in the desired state.

Parameters:
  • name (Text) – Service unit name (e.g. “nginx”, “nginx.service”)

  • started (bool) – Whether the service should be running

  • enabled (bool) – Whether the service should start on boot

Return type:

Result

static daemon_reload()[source]

Reload systemd manager configuration.

Return type:

None

static disable(name)[source]

Disable a service at boot. No-op if already disabled.

Return type:

Result

static enable(name)[source]

Enable a service at boot. No-op if already enabled.

Return type:

Result

static reload(name)[source]

Reload a service unconditionally (SIGHUP).

Return type:

Result

static restart(name)[source]

Restart a service unconditionally.

Return type:

Result

static start(name)[source]

Start a service. No-op if already running.

Return type:

Result

static status(name)[source]

Return current active/enabled status of a service.

Return type:

Result

static stop(name)[source]

Stop a service. No-op if already stopped.

Return type:

Result