SaltDns.Release (Salt v1.0.0)

Tasks for a running release, where Mix is not available:

bin/salt_dns eval SaltDns.Release.migrate
bin/salt_dns eval 'SaltDns.Release.rollback(SaltDns.Repo, 20261110190045)'
bin/salt_dns eval SaltDns.Release.rotate_vault
bin/salt_dns eval SaltDns.Release.create_user_from_env
bin/salt_dns eval 'SaltDns.Release.sign_out_user("me@example.com")'
bin/salt_dns eval SaltDns.Release.duplicate_outside_routes
bin/salt_dns eval SaltDns.Release.address_collisions
bin/salt_dns eval 'SaltDns.Release.create_organisation("My company")'
bin/salt_dns eval 'SaltDns.Release.invite("me@example.com", 1, :owner)'
bin/salt_dns eval 'IO.puts(SaltDns.Release.create_provisioning_token(1, "me@example.com", "billing"))'

bin/migrate is the first one. See docs/operations.md.

Summary

Functions

Prints the addresses that reporting nodes of more than one organisation claim, which group keeps each (the older claim) and which are refused. For the operator; HTTP-01 certificates of a refused group fail their pre-check with a message that says so.

Assigns an address that several organisations claim to one proxy group (the operator's decision, audited in the group's change history). The group still needs a reporting node with the address typed in. The remedy for a node whose connection address differs from its public address and so can never corroborate it.

Adds a certificate provider shared by every organisation of the installation and registers its account (docs/certificates.md). opts may hold :contact, :eab_kid, :eab_hmac_key, :profile. Needs SALT_DNS_CERTIFICATES=on. Raises with the reason when the provider cannot be added or registered.

Creates an organisation with no members and returns its id. For a fresh installation that only lets invited people in (SALT_DNS_OIDC_AUTO_CREATE=invited): nobody can create the first organisation there, so make it here and then invite/3 its first owner.

Creates a provisioning token for an organisation (see SaltDns.Provisioning and docs/integrations/provisioning.md) and returns it; it is not stored and cannot be shown again. owner_email must belong to an owner or admin of the organisation. Raises when the organisation or the user is not found or may not do this. Option registrar: :read | :purchase gives the token access to the registrar API (docs/registrar.md); the default is :none.

Creates a confirmed user with a password, for the first sign-in when no mail delivery or single sign-on is set up yet. Returns the e-mail address; raises with the reasons when the address or password is not acceptable. Needs password login to be on.

create_user/2 with SALT_DNS_FIRST_USER_EMAIL and SALT_DNS_FIRST_USER_PASSWORD, which keep the password out of the command line. Set them for this one command only.

Prints the hosts in no zone of Salt that more than one proxy group routes (see SaltDns.Proxy.duplicate_outside_routes/0). No certificate is ordered for such a host until all but one route is removed; the operator decides which group keeps it.

Invites an e-mail address that has no user yet to an organisation, as the operator, and returns the invitation id. role is :owner, :admin, :editor or :viewer (or the same word as a string). The invitation lasts 14 days. With SALT_DNS_OIDC_AUTO_CREATE=invited the person's first sign-in through the identity provider then creates their user and the membership. Nothing is sent: tell the person. Raises with the reason when the organisation is not found, the address already has a user (add that user as a member in the console instead) or the address or role is not acceptable.

Runs all pending migrations.

Lets an organisation use a shared registrar provider (one with no organisation, made by the operator): the organisation's API tokens with a registrar level, and through a provisioning token its customers' domains, are then served by that registrar account. Without this an organisation has no provider through a shared account at any level, not even to read its balance. Returns the list of allowed organisation ids. Raises when the provider or the organisation does not exist or the provider is not shared. Only the operator can do this: no console page and no API call reaches it.

Takes an organisation off the list of a shared registrar provider (see registrar_allow/2).

Rolls back to (and including) version.

Re-encrypts every stored secret with the active vault key, so a retired key can be dropped (SaltDns.Vault). Safe to repeat. Returns the number of values rewritten.

Registers a node from an offline enrolment request and prints the bootstrap file as JSON (contract 3.2, the offline path). Returns the same map.

Creates an enrolment token for a Shaker proxy group and returns it. It is shown once and not stored (see SaltDns.Shaker and docs/shaker.md).

Ends every session of the user with this e-mail address (password and single sign-on sessions) and prints how many were removed. An address with no user prints a message and changes nothing. Returns {:ok, count} or {:error, :not_found}.

Removes such an assignment: the claims decide again.

Functions

address_collisions()

@spec address_collisions() :: :ok

Prints the addresses that reporting nodes of more than one organisation claim, which group keeps each (the older claim) and which are refused. For the operator; HTTP-01 certificates of a refused group fail their pre-check with a message that says so.

bin/salt_dns eval 'SaltDns.Release.address_collisions()'

assign_address(address, group_id, operator \\ "operator")

@spec assign_address(String.t(), integer(), String.t()) :: :ok | {:error, atom()}

Assigns an address that several organisations claim to one proxy group (the operator's decision, audited in the group's change history). The group still needs a reporting node with the address typed in. The remedy for a node whose connection address differs from its public address and so can never corroborate it.

bin/salt_dns eval 'SaltDns.Release.assign_address("203.0.113.7", 12, "your name")'

certificate_provider(name, directory_url, opts \\ [])

@spec certificate_provider(String.t(), String.t(), keyword()) :: String.t()

Adds a certificate provider shared by every organisation of the installation and registers its account (docs/certificates.md). opts may hold :contact, :eab_kid, :eab_hmac_key, :profile. Needs SALT_DNS_CERTIFICATES=on. Raises with the reason when the provider cannot be added or registered.

bin/salt_dns eval 'SaltDns.Release.certificate_provider("main", "https://ca.example/directory", contact: "ops@example.org")'

create_organisation(name)

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

Creates an organisation with no members and returns its id. For a fresh installation that only lets invited people in (SALT_DNS_OIDC_AUTO_CREATE=invited): nobody can create the first organisation there, so make it here and then invite/3 its first owner.

bin/salt_dns eval 'SaltDns.Release.create_organisation("My company")'

create_provisioning_token(organisation_id, owner_email, name, opts \\ [])

@spec create_provisioning_token(integer(), String.t(), String.t(), keyword()) ::
  String.t()

Creates a provisioning token for an organisation (see SaltDns.Provisioning and docs/integrations/provisioning.md) and returns it; it is not stored and cannot be shown again. owner_email must belong to an owner or admin of the organisation. Raises when the organisation or the user is not found or may not do this. Option registrar: :read | :purchase gives the token access to the registrar API (docs/registrar.md); the default is :none.

bin/salt_dns eval 'IO.puts(SaltDns.Release.create_provisioning_token(1, "me@example.com", "billing system"))'

With access to the registrar API (only with SALT_DNS_REGISTRAR=on):

bin/salt_dns eval 'IO.puts(SaltDns.Release.create_provisioning_token(1, "me@example.com", "domains", registrar: :purchase))'

create_user(email, password)

@spec create_user(String.t(), String.t()) :: String.t()

Creates a confirmed user with a password, for the first sign-in when no mail delivery or single sign-on is set up yet. Returns the e-mail address; raises with the reasons when the address or password is not acceptable. Needs password login to be on.

create_user_from_env()

@spec create_user_from_env() :: String.t()

create_user/2 with SALT_DNS_FIRST_USER_EMAIL and SALT_DNS_FIRST_USER_PASSWORD, which keep the password out of the command line. Set them for this one command only.

duplicate_outside_routes()

@spec duplicate_outside_routes() :: :ok

Prints the hosts in no zone of Salt that more than one proxy group routes (see SaltDns.Proxy.duplicate_outside_routes/0). No certificate is ordered for such a host until all but one route is removed; the operator decides which group keeps it.

bin/salt_dns eval 'SaltDns.Release.duplicate_outside_routes()'

invite(email, organisation_id, role)

@spec invite(String.t(), integer(), atom() | String.t()) :: integer()

Invites an e-mail address that has no user yet to an organisation, as the operator, and returns the invitation id. role is :owner, :admin, :editor or :viewer (or the same word as a string). The invitation lasts 14 days. With SALT_DNS_OIDC_AUTO_CREATE=invited the person's first sign-in through the identity provider then creates their user and the membership. Nothing is sent: tell the person. Raises with the reason when the organisation is not found, the address already has a user (add that user as a member in the console instead) or the address or role is not acceptable.

bin/salt_dns eval 'SaltDns.Release.invite("me@example.com", 1, :owner)'

migrate()

@spec migrate() :: :ok

Runs all pending migrations.

registrar_allow(provider_id, organisation_id)

@spec registrar_allow(integer(), integer()) :: [integer()]

Lets an organisation use a shared registrar provider (one with no organisation, made by the operator): the organisation's API tokens with a registrar level, and through a provisioning token its customers' domains, are then served by that registrar account. Without this an organisation has no provider through a shared account at any level, not even to read its balance. Returns the list of allowed organisation ids. Raises when the provider or the organisation does not exist or the provider is not shared. Only the operator can do this: no console page and no API call reaches it.

bin/salt_dns eval 'IO.inspect(SaltDns.Release.registrar_allow(1, 42))'

registrar_disallow(provider_id, organisation_id)

@spec registrar_disallow(integer(), integer()) :: [integer()]

Takes an organisation off the list of a shared registrar provider (see registrar_allow/2).

rollback(repo, version)

@spec rollback(module(), integer()) :: :ok

Rolls back to (and including) version.

rotate_vault()

@spec rotate_vault() :: non_neg_integer()

Re-encrypts every stored secret with the active vault key, so a retired key can be dropped (SaltDns.Vault). Safe to repeat. Returns the number of values rewritten.

shaker_bootstrap(request_base64url, group)

@spec shaker_bootstrap(String.t(), String.t()) :: map()

Registers a node from an offline enrolment request and prints the bootstrap file as JSON (contract 3.2, the offline path). Returns the same map.

bin/salt_dns eval 'SaltDns.Release.shaker_bootstrap("<request>", "edge")'

shaker_token(group)

@spec shaker_token(String.t()) :: String.t()

Creates an enrolment token for a Shaker proxy group and returns it. It is shown once and not stored (see SaltDns.Shaker and docs/shaker.md).

bin/salt_dns eval 'SaltDns.Release.shaker_token("edge")'

sign_out_user(email)

@spec sign_out_user(String.t()) :: {:ok, non_neg_integer()} | {:error, :not_found}

Ends every session of the user with this e-mail address (password and single sign-on sessions) and prints how many were removed. An address with no user prints a message and changes nothing. Returns {:ok, count} or {:error, :not_found}.

This runs in its own Erlang VM, so pages the person already has open are not disconnected; they end at the next load or reconnect. The person can sign in again unless they are disabled at the identity provider.

bin/salt_dns eval 'SaltDns.Release.sign_out_user("me@example.com")'

unassign_address(address, operator \\ "operator")

@spec unassign_address(String.t(), String.t()) :: :ok

Removes such an assignment: the claims decide again.