SaltDns.Knot.OrgConfig (Salt v1.0.0)

The Knot configuration one organisation needs for distribution, and the configuration transaction that makes Knot match it. Pure.

For organisation o with secondaries s1..sn this is:

key[<key name>]       one per secondary: the transfer TSIG key
remote[sec-o-s]       the secondary's addresses and key (for NOTIFY)
acl[sec-o-s]          transfer only, from the secondary's addresses
                      (and any extra sources) and with its key
                      (both must match)
zone[oO.catalog.invalid]   the organisation's catalog zone, generated
                      by Knot; ACL and NOTIFY only for secondaries that
                      consume the catalog
template[org-o]       what the organisation's active zones use: member
                      of that catalog, ACL and NOTIFY for every
                      secondary (plus the base ones, the edge's)

A secondary therefore can transfer only its own organisation's zones and catalog, and only with its own key from its own addresses.

plan/2 takes the desired spec and Knot's current items (parsed conf-read output) and returns the conf-set/conf-unset argument lists for one transaction; an empty plan means Knot already matches and no transaction should be opened (a commit would reload the organisation's zones).

Summary

Types

{section, id} mapped to item => [values], values as Knot prints them.

Functions

Name of the organisation's catalog zone (no trailing dot).

The items Knot should have for the spec.

The edges in parsed remotes/remote items: the members of the groups groups, each with its addresses split into host and port. A remote that does not exist is skipped; a loopback or unspecified address (the placeholder of an edge that is not set up yet) is dropped, and so is a remote left with no address.

Prefix of the ids of an organisation's remotes and ACLs.

Suffix of the TSIG key names generated for an organisation's secondaries.

Parses knotc conf-read output into items. Each value line is section[id].item value; a multi-value item continues on the following lines without a prefix. A line section.id <id> only declares the section. Lines that do not parse are ignored.

The argument lists (without the leading knotc options) of one config transaction that turns actual into the desired items of spec, or [].

Name of the member template of the organisation's active zones.

Types

items()

@type items() :: %{
  required({String.t(), String.t()}) => %{required(String.t()) => [String.t()]}
}

{section, id} mapped to item => [values], values as Knot prints them.

secondary()

@type secondary() :: %{
  :id => integer(),
  :key_name => String.t(),
  :algorithm => String.t(),
  :secret => String.t(),
  :addresses => [String.t()],
  optional(:extra_sources) => [String.t()],
  :consumes_catalog => boolean(),
  optional(:sign_zone_transfers) => boolean()
}

settings()

@type settings() :: %{base_acls: [String.t()], base_notify: [String.t()]}

spec()

@type spec() :: %{organisation_id: integer(), secondaries: [secondary()]}

Functions

catalog_zone(organisation_id)

@spec catalog_zone(integer()) :: String.t()

Name of the organisation's catalog zone (no trailing dot).

desired(map, settings)

@spec desired(spec(), settings()) :: items()

The items Knot should have for the spec.

edges(items, groups)

@spec edges(items(), [String.t()]) :: [SaltDns.Knot.edge()]

The edges in parsed remotes/remote items: the members of the groups groups, each with its addresses split into host and port. A remote that does not exist is skipped; a loopback or unspecified address (the placeholder of an edge that is not set up yet) is dropped, and so is a remote left with no address.

id_prefix(organisation_id)

@spec id_prefix(integer()) :: String.t()

Prefix of the ids of an organisation's remotes and ACLs.

key_suffix(organisation_id)

@spec key_suffix(integer()) :: String.t()

Suffix of the TSIG key names generated for an organisation's secondaries.

parse(output)

@spec parse(String.t()) :: items()

Parses knotc conf-read output into items. Each value line is section[id].item value; a multi-value item continues on the following lines without a prefix. A line section.id <id> only declares the section. Lines that do not parse are ignored.

plan(spec, actual, settings)

@spec plan(spec(), items(), settings()) :: [[String.t()]]

The argument lists (without the leading knotc options) of one config transaction that turns actual into the desired items of spec, or [].

actual should hold the organisation's template, catalog zone and every key, remote and acl section Knot has (they are filtered here to the organisation's own). Stale secondaries (this organisation's, no longer in the spec) are removed.

template(organisation_id)

@spec template(integer()) :: String.t()

Name of the member template of the organisation's active zones.