Skip to content

lkubb/salt-nginx-formula

Repository files navigation

Nginx Formula

Semantic Release pre-commit

Manage Nginx with Salt.

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:

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:

Meta-state.

This installs the nginx package and possibly repository, manages the nginx configuration file plus snippets, manages webroot dirs, generates DH params if requested (discouraged), starts the associated nginx service and manages server configurations.

Installs the nginx package only. If installation from repo is configured, will also configure the selected repo.

This state will install the configured nginx repository. This works for apt/dnf/yum/zypper-based distributions only by default.

Generates certificates for servers that have certs set. Also generates Diffie-Hellman key exchange parameters, if requested. This is discouraged. Has a dependency on nginx.config.

Manages the nginx service configuration. Has a dependency on nginx.package.

Manages Nginx snippets. Has a dependency on nginx.package.

Ensures configured webroot directories are present. Has a dependency on nginx.package.

Starts the nginx service (and session key rotation service, if configured) and enables it at boot time. Has a dependency on nginx.config.

Manages server configurations and their state (enabled/disabled). Has a dependency on nginx.service.

Meta-state.

Undoes everything performed in the nginx meta-state in reverse order, i.e. removes managed server configurations, stops the service, removes webroots if nginx.lookup.remove_all_data_for_sure is True, removes snippets, the configuration file and possibly generated DH params and then uninstalls the package and possibly repository.

Removes the nginx package and nginx repositories. Has a dependency on nginx.config.clean.

This state will remove the configured nginx repository. This works for apt/dnf/yum/zypper-based distributions only by default.

Removes generated certificates, private keys and DH parameters. Has a dependency on nginx.service.clean.

Removes the configuration of the nginx service and has a dependency on nginx.service.clean.

Removes all managed snippets.

Removes configured webroot directories if nginx.lookup.remove_all_data_for_sure is True. Has a dependency on nginx.service.clean.

Stops the nginx service (and session key rotation service, if configured) and disables it at boot time.

Removes all managed server configurations.

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.