User:Maffblaster/Drafts/serf

From Gentoo Wiki
Jump to:navigation Jump to:search

serf is a service orchestration and management tool written in Go. It is very useful as a scriptable event handler.

Installation

USE flags

USE flags for app-admin/serf Service orchestration and management tool

Emerge

root #emerge --ask app-admin/serf

Additional software

Todo...

Configuration

Files

  • /etc/serf.d - Global (system wide) configuration directory. When serf agent is invoked either by OpenRC and or systemd, all files in this directory ending in .json will be passed to the agent. Upstream documentation on json options can be found here.

example json

The following is an example of how a json file can be added to the /etc/serf.d directory:

FILE /etc/serf.d/larry-workstation.jsonAssign tags, event handles, and specify an interface
{
  "tags": {
    "role": "workstation-laptop",
    "network": "roaming"
  },
  "event_handlers": [
    "handle.sh",
    "user:deploy=deploy.sh"
  ],
"interface": "wg0"
}

Service

OpenRC

Add serf to the default runlevel:

root #rc-update add serf default

Start the service:

root #rc-service serf start

systemd

Enable and start the service:

root #systemctl enable --now serf

Usage

Invocation

user $serf --help
Usage: serf [--version] [--help] <command> [<args>]

Available commands are:
    agent           Runs a Serf agent
    event           Send a custom event through the Serf cluster
    force-leave     Forces a member of the cluster to enter the "left" state
    info            Provides debugging information for operators
    join            Tell Serf agent to join cluster
    keygen          Generates a new encryption key
    keys            Manipulate the internal encryption keyring used by Serf
    leave           Gracefully leaves the Serf cluster and shuts down
    members         Lists the members of a Serf cluster
    monitor         Stream logs from a Serf agent
    query           Send a query to the Serf cluster
    reachability    Test network reachability
    rtt             Estimates network round trip time between nodes
    tags            Modify tags of a running Serf agent
    version         Prints the Serf version

Removal

Unmerge

root #emerge --ask --depclean --verbose app-admin/serf

See also

  • WireGuard — a modern, simple, and secure VPN that utilizes state-of-the-art cryptography.

References