sr2c.podman.podman_nginx role – Deploy nginx with Let’s Encrypt certificates using rootless Podman
Note
This role is part of the sr2c.podman collection (version 0.0.1).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it use: ansible-galaxy collection install sr2c.podman.
To use it in a playbook, specify: sr2c.podman.podman_nginx.
Entry point main – Deploy nginx with Let’s Encrypt certificates using rootless Podman
Synopsis
Runs nginx as a quadlet container for
podman_nginx_podman_rootless_user, and gets a Let’s Encrypt certificate forpodman_nginx_primary_hostnameandpodman_nginx_additional_hostnameswith certbot. Run sr2c.podman.podman_host for the user first.nginx reads its configuration from
~/nginx, mounted as/etc/nginx/conf.d. Until a certificate exists, the role writes a temporarynginx.confthere that answers the ACME challenge and redirects everything else to HTTPS. Once the certificate exists, it replaces that withpodman_nginx_config.Certificates are kept in
~/certbot/conf, mounted as/etc/letsencrypt, so the certificate is/etc/letsencrypt/live/<primary hostname>/fullchain.peminside the container. The calling role’s configuration must serve/.well-known/acme-challenge/on port 80 from/var/www/certbot, for renewals and when the hostnames change.When the hostnames change, the certificate is issued again with the new names. A timer runs
certbot renewdaily, and nginx restarts weekly to load renewed certificates.Opens the
httpandhttpsservices in the firewalld zonepodman_nginx_firewalld_zone.With socket activation,
nginx.socketlistens on ports 80 and 443 and starts nginx on the first connection. The socket is enabled, so it starts at boot withpodman_nginx_systemd_service_target, or withdefault.targetwhen there is no target.
Parameters
Parameter |
Comments |
|---|---|
Other hostnames to include in the certificate. Default: |
|
Extra volumes to mount in the nginx container, for example static files the application writes. Default: |
|
The path inside the container. |
|
The mount options, for example |
|
The path on the host. |
|
The certbot container image. Default: |
|
Get certificates from the Let’s Encrypt staging environment, which browsers don’t trust but which has much higher rate limits. Use it for testing. Choices:
|
|
The nginx configuration, written to The calling role renders it, for example with When not set, the calling role must write its own configuration to |
|
The firewalld zone to open the Default: |
|
A network to attach nginx to, by the name of its quadlet without |
|
The nginx container image. Default: |
|
The rootless Podman user that runs nginx. The calling role passes its own |
|
The hostname nginx serves, and the name of the certificate. |
|
Start nginx with systemd socket activation, from
Choices:
|
|
Units that nginx requires and starts after, for example A name without a unit suffix is taken as a service, with a deprecation warning. Give the full unit name. Default: |
|
The slice to run nginx in, usually the stack’s slice. |
|
The stack’s target. nginx and When this is set, the nginx container is also wanted by |