julienpalard.nginx_letsencrypt

Nginx with Letsencrypt

This role sets up nginx with letsencrypt.

It tries to be minimal by just creating snippets in /etc/nginx/snippets/letsencrypt-{your.domain}.conf so you can configure nginx yourself as you which.

Role Variables

The only mandatory variables are:

  • letsencrypt_certificates: A list of certificates, each being a list of domain names.
  • letsencrypt_email: Your email address.

Optional variables are:

Example Playbook

One certificate, one domain

Simpliest playbook with a single certificate and a single domain would look like:

- hosts: static_websites
  roles:
    - role: julienpalard.nginx_letsencrypt
      vars:
        letsencrypt_certificates: [[mdk.fr]]
        letsencrypt_email: [email protected]

Note the double brackets, it's because we're asking for a single domain in a single certificate, see following examples for clarification.

One certificate, multiple domains

Just add your domains to the inner list, like:

- hosts: static_websites
  roles:
    - role: julienpalard.nginx_letsencrypt
      vars:
        letsencrypt_certificates: [[mdk.fr, www.mdk.fr]]
        letsencrypt_email: [email protected]

Multiple certificates, multiple domains

The following playbook will generate three differnt certificates, the first one valid for mdk.fr, www.mdk.fr, and julien.palard.fr, the second one for wyz.fr and www.wyz.fr and the last one valid for tuw.fr and www.tuz.fr:

- hosts: static_websites
  roles:
    - role: julienpalard.nginx_letsencrypt
      vars:
        letsencrypt_certificates:
          - [mdk.fr, www.mdk.fr, julien.palard.fr]
          - [wyz.fr, www.wyz.fr]
          - [tuw.fr, www.tuw.fr]
        letsencrypt_email: [email protected]

As a role dependency

This role fit nicely as another role dependency (in meta/main.yml), but do not use roles, use include_role, see ansible#34736:

dependencies:
  - role: julienpalard.nginx_letsencrypt
    vars:
      letsencrypt_certificates: [["{{ domain }}"]]

Or to concatenate a domain with a list of extra domains:

dependencies:
  - role: julienpalard.nginx_letsencrypt
    vars:
      letsencrypt_certificates: ["{{ [domain] | union(extra_certificates) }}"]

You can even extract the domain names from attributes of a map:

dependencies:
  - role: julienpalard.nginx_letsencrypt
    letsencrypt_certificates: {{ projects|map(attribute='domain')|list }}

License

MIT

Author Information

Julien Palard — https://mdk.fr

Install
ansible-galaxy install julienpalard.nginx_letsencrypt
GitHub repository
License
Unknown
Downloads
128
Owner
@python Core Developer