propellor-5.17: property-based host configuration management in haskell

Safe Haskell | Safe-Inferred
Language | Haskell2010

Propellor.Property.Systemd

Contents

- Services
- Configuration
- Journal
- Logind
- Containers and machined
- Container configuration

Synopsis

- type ServiceName = String
- started :: ServiceName -> Property Linux
- stopped :: ServiceName -> Property Linux
- enabled :: ServiceName -> Property Linux
- disabled :: ServiceName -> Property Linux
- masked :: ServiceName -> RevertableProperty Linux Linux
- running :: ServiceName -> Property Linux
- restarted :: ServiceName -> Property Linux
- networkd :: ServiceName
- journald :: ServiceName
- logind :: ServiceName
- escapePath :: FilePath -> String
- installed :: Property DebianLike
- type Option = String
- configured :: FilePath -> Option -> String -> Property Linux
- daemonReloaded :: Property Linux
- persistentJournal :: Property DebianLike
- journaldConfigured :: Option -> String -> Property Linux
- logindConfigured :: Option -> String -> Property Linux
- killUserProcesses :: RevertableProperty Linux Linux
- machined :: Property Linux
- type MachineName = String
- data Container
- container :: MachineName -> (FilePath -> Chroot) -> Container
- debContainer :: MachineName -> Props metatypes -> Container
- nspawned :: Container -> RevertableProperty (HasInfo + Linux) Linux
- containerCfg :: String -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
- resolvConfed :: RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
- linkJournal :: RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
- privateNetwork :: RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
- module Propellor.Types.Container
- data Proto
  - = TCP
  - | UDP
- class Publishable a
- publish :: Publishable p => p -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
- class Bindable a
- bind :: Bindable p => p -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux)
- bindRo :: Bindable p => p -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux)

# Services

type ServiceName = String Source #

started :: ServiceName -> Property Linux Source #

Starts a systemd service.

Note that this does not configure systemd to start the service on boot, it only ensures that the service is currently running.

stopped :: ServiceName -> Property Linux Source #

Stops a systemd service.

enabled :: ServiceName -> Property Linux Source #

Enables a systemd service.

This does not ensure the service is started, it only configures systemd to start it on boot.

disabled :: ServiceName -> Property Linux Source #

Disables a systemd service.

masked :: ServiceName -> RevertableProperty Linux Linux Source #

Masks a systemd service.

running :: ServiceName -> Property Linux Source #

Ensures that a service is both enabled and started

restarted :: ServiceName -> Property Linux Source #

Restarts a systemd service.

networkd :: ServiceName Source #

The systemd-networkd service.

journald :: ServiceName Source #

The systemd-journald service.

logind :: ServiceName Source #

The systemd-logind service.

escapePath :: FilePath -> String Source #

Escapes a path for inclusion in a systemd unit name, the same as systemd-escape does.

# Configuration

installed :: Property DebianLike Source #

type Option = String Source #

configured :: FilePath -> Option -> String -> Property Linux Source #

Ensures that an option is configured in one of systemd's config files. Does not ensure that the relevant daemon notices the change immediately.

This assumes that there is only one [Header] per file, which is currently the case for files like journald.conf and system.conf. And it assumes the file already exists with the right [Header], so new lines can just be appended to the end.

daemonReloaded :: Property Linux Source #

Causes systemd to reload its configuration files.

# Journal

persistentJournal :: Property DebianLike Source #

Enables persistent storage of the journal.

journaldConfigured :: Option -> String -> Property Linux Source #

Configures journald, restarting it so the changes take effect.

# Logind

logindConfigured :: Option -> String -> Property Linux Source #

Configures logind, restarting it so the changes take effect.

killUserProcesses :: RevertableProperty Linux Linux Source #

Configures whether leftover processes started from the user's login session are killed after the user logs out.

The default configuration varies depending on the version of systemd.

Revert the property to ensure that screen sessions etc keep running:

    	! killUserProcesses

# Containers and machined

machined :: Property Linux Source #

Ensures machined and machinectl are installed

type MachineName = String Source #

data Container Source #

#### Instances

Instances details

Show Container Source # |
Instance details Defined in Propellor.Property.Systemd Methods showsPrec :: Int -> Container -> ShowS show :: Container -> String showList :: [Container] -> ShowS
IsContainer Container Source # |
Instance details Defined in Propellor.Property.Systemd Methods containerProperties :: Container -> [ChildProperty] Source # containerInfo :: Container -> Info Source # setContainerProperties :: Container -> [ChildProperty] -> Container Source #

container :: MachineName -> (FilePath -> Chroot) -> Container Source #

Defines a container with a given machine name, and how to create its chroot if not already present.

Properties can be added to configure the Container. At a minimum, add a property such as `osDebian` to specify the operating system to bootstrap.

    container "webserver" $ \d -> Chroot.debootstrapped mempty d $ props
       & osDebian Unstable X86_64
       & Apt.installedRunning "apache2"
       & ...

debContainer :: MachineName -> Props metatypes -> Container Source #

Defines a container with a given machine name, with the chroot created using debootstrap.

Properties can be added to configure the Container. At a minimum, add a property such as `osDebian` to specify the operating system to bootstrap.

    debContainer "webserver" $ props
       & osDebian Unstable X86_64
       & Apt.installedRunning "apache2"
       & ...

nspawned :: Container -> RevertableProperty (HasInfo + Linux) Linux Source #

Runs a container using systemd-nspawn.

A systemd unit is set up for the container, so it will automatically be started on boot.

Systemd is automatically installed inside the container, and will communicate with the host's systemd. This allows systemctl to be used to examine the status of services running inside the container.

When the host system has persistentJournal enabled, journactl can be used to examine logs forwarded from the container.

Reverting this property stops the container, removes the systemd unit, and deletes the chroot and all its contents.

# Container configuration

containerCfg :: String -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

This configures how systemd-nspawn(1) starts the container, by specifying a parameter, such as "--private-network", or "--link-journal=guest"

When there is no leading dash, "--" is prepended to the parameter.

Reverting the property will remove a parameter, if it's present.

resolvConfed :: RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

Bind mounts /etc/resolv.conf from the host into the container.

This is not necessary when systemd configures the container's resolv.conf on its own. This used to be enabled by default, but when systemd did also configure the container's resolv.conf, that could modify the host's resolv.conf.

linkJournal :: RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

Link the container's journal to the host's if possible. (Only works if the host has persistent journal enabled.)

This property is enabled by default. Revert it to disable it.

privateNetwork :: RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

Disconnect networking of the container from the host.

module Propellor.Types.Container

data Proto Source #

Constructors

TCP |
UDP |

#### Instances

Instances details

Publishable (Proto, Bound Port) Source # |
Instance details Defined in Propellor.Property.Systemd Methods toPublish :: (Proto, Bound Port) -> String

class Publishable a Source #

Minimal complete definition

toPublish

#### Instances

Instances details

Publishable Port Source # |
Instance details Defined in Propellor.Property.Systemd Methods toPublish :: Port -> String
Publishable (Bound Port) Source # |
Instance details Defined in Propellor.Property.Systemd Methods toPublish :: Bound Port -> String
Publishable (Proto, Bound Port) Source # |
Instance details Defined in Propellor.Property.Systemd Methods toPublish :: (Proto, Bound Port) -> String

publish :: Publishable p => p -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

Publish a port from the container to the host.

This feature was first added in systemd version 220.

This property is only needed (and will only work) if the container is configured to use private networking. Also, networkd should be enabled both inside the container, and on the host. For example:

     foo :: Host
     foo = host "foo.example.com"
    	& Systemd.nspawned webserver
     		`requires` Systemd.running Systemd.networkd

     webserver :: Systemd.container
     webserver = Systemd.container "webserver" (Chroot.debootstrapped mempty)
    	& os (System (Debian Testing) X86_64)
    	& Systemd.privateNetwork
    	& Systemd.running Systemd.networkd
    	& Systemd.publish (Port 80 ->- Port 8080)
    	& Apt.installedRunning "apache2"

class Bindable a Source #

Minimal complete definition

toBind

#### Instances

Instances details

Bindable FilePath Source # |
Instance details Defined in Propellor.Property.Systemd Methods toBind :: FilePath -> String
Bindable (Bound FilePath) Source # |
Instance details Defined in Propellor.Property.Systemd Methods toBind :: Bound FilePath -> String

bind :: Bindable p => p -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

Bind mount a file or directory from the host into the container.

bindRo :: Bindable p => p -> RevertableProperty (HasInfo + Linux) (HasInfo + Linux) Source #

Read-only mind mount.