Skip to content

lkubb/salt-truenas-formula

Repository files navigation

TrueNAS Formula

Semantic Release pre-commit

Manage TrueNAS with Salt.

This is a collection of states intended to be run over Salt-SSH.

See the full SaltStack Formulas installation and usage instructions.

If you are interested in writing or contributing to formulas, please pay attention to the Writing Formula Section.

If you want to use this formula, please pay attention to the FORMULA file and/or git tag, which contains the currently released version. This formula is versioned according to Semantic Versioning.

See Formula Versioning Section for more details.

If you need (non-default) configuration, please refer to:

  • This formula is intended to be executed via salt-ssh.
  • It currently relies heavily on wrapper modules that are not yet part of Salt core, but are submitted in several of my PRs.

An example pillar is provided, please see pillar.example. Note that you do not need to specify everything by pillar. Often, it's much easier and less resource-heavy to use the parameters/<grain>/<value>.yaml files for non-sensitive settings. The underlying logic is explained in map.jinja.

The following states are found in this formula:

A collection of states to manage some aspects of TrueNAS. You will have to target each mod explicitly, just truenas does nothing.

Manages certificates that will be imported into the certificate store.

When using a ca_server, will rely on the SSH wrapper emulation of x509.certificate_managed since the remote does not have access to the event bus.

The wrapper is found in my PR #65654 or in my formula for a private CA: https://github.com/lkubb/salt-private-ca-formula

Manages the MinIO plugin.

Currently only manages a certificate.

Manages a certificate for the MinIO plugin.

The jail must exist for this state to work at all.

Manages the SSH service.

Manages OpenSSH authorized keys. If TrustedUserCAKeys has been specified in the server configuration (truenas:sshd:config), all CA keys from truenas:sshd:trusted_user_ca_keys will be serialized into the corresponding file as well.

Manages SSH configuration. TrueNAS automatically reloads the config, so this is mostly standalone. It still depends on truenas.sshd.host_pki since those should be managed before.

Manages SSH host keys and other related files.

Ensures SSH service is enabled and running. No config since SSH is required for any of this to work.

Installs Telegraf and manages configuration.

You need to set truenas:telegraf:destination. It is advised to install it on a dataset to avoid it being removed during an update.

Does not remove the certificates/keys because this is hard to automate and can break a lot of things. You will need to do this manually.

Removes managed OpenSSH authorized keys and trusted user CA keys.

Removes Telegraf and configuration.

Commit messages

Commit message formatting is significant!

Please see How to contribute for more details.

pre-commit

pre-commit is configured for this formula, which you may optionally use to ease the steps involved in submitting your changes. First install the pre-commit package manager using the appropriate method, then run bin/install-hooks and now pre-commit will run automatically on each git commit.

$ bin/install-hooks
pre-commit installed at .git/hooks/pre-commit
pre-commit installed at .git/hooks/commit-msg

State documentation

There is a script that semi-autodocuments available states: bin/slsdoc.

If a .sls file begins with a Jinja comment, it will dump that into the docs. It can be configured differently depending on the formula. See the script source code for details currently.

This means if you feel a state should be documented, make sure to write a comment explaining it.