systemd adapter

Inmanta module to manage systemd services.

Features

This module supports: - Starting and stopping a service. - Enabling and disabling a service. - Managing a systemd service file. - Managing a systemd timer file.

Usage example

Here is a simple example of managing a service that only sleeps and its service unit file on a remote host via ssh.

import systemd
import mitogen

unit = systemd::Unit(
    host=host,
    name="test",
    content="""
        [Unit]
        Description=Test daemon
        Before=default.target

        [Service]
        ExecStart=/bin/sleep 12345

        [Install]
        WantedBy=default.target
    """,
    purged=false,
)

svc = systemd::Service(
    host=host,
    name="test",
    state="running",
    onboot=true,
    unit=unit,
)

host = std::Host(
    name="server",
    os=std::linux,
    via=mitogen::Sudo(
        via=mitogen::Ssh(
            name="server",
            hostname="1.2.3.4",
            port=22,
            username="user",
        ),
    ),
)