Fork of github.com/cosandr/ansible-role-lego
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pavel Valach c8378851df
Some checks failed
/ molecule (push) Has been cancelled
(chore) Use ansible_facts to silence warnings
2026-07-09 11:00:10 +02:00
.github/workflows Fix CI? 2023-10-31 23:01:40 +01:00
defaults Use declarative config, deploy hooks, issue and renew certs via the same service file 2026-07-02 18:23:47 +02:00
handlers Set SELinux context for certificates 2023-12-05 20:21:20 +01:00
meta Initial commit 2023-10-31 22:58:16 +01:00
molecule Use declarative config, deploy hooks, issue and renew certs via the same service file 2026-07-02 18:23:47 +02:00
tasks (chore) Use ansible_facts to silence warnings 2026-07-09 11:00:10 +02:00
templates Use declarative config, deploy hooks, issue and renew certs via the same service file 2026-07-02 18:23:47 +02:00
vars (chore) Use ansible_facts to silence warnings 2026-07-09 11:00:10 +02:00
.editorconfig Initial commit 2023-10-31 22:58:16 +01:00
.gitignore Initial commit 2023-10-31 22:58:16 +01:00
.gitlab-ci.yml Fix CI? 2023-10-31 23:01:40 +01:00
.yamllint.yml Initial commit 2023-10-31 22:58:16 +01:00
LICENSE Initial commit 2023-10-31 22:58:16 +01:00
README.md Use declarative config, deploy hooks, issue and renew certs via the same service file 2026-07-02 18:23:47 +02:00
requirements.yml Initial commit 2023-10-31 22:58:16 +01:00

ansible-role-lego

GitHub GitHub last commit GitHub issues

Ansible role for setting up lego.

Supported Platforms

OS Family Distribution Latest Supported Version(s) Comment
RedHat RHEL ✔️ 9
RockyLinux ✔️ 8, 9
AlmaLinux ✔️ 8, 9
Fedora ✔️ 36, 37, 38

Requirements

Ansible 2.12 or higher.

Variables

Name Default Value Description
lego_version latest Set Lego version, can be specific version, i.e. v4.14.2
lego_renew_oncalendar *-*-* 00/12:00:00 Sets systemd timer schedule
lego_renew_random_delay 1h Sets systemd timer random delay
lego_pre_script "" Raw string inserted in lego-wrapper
lego_home /etc/lego Path to store files, including accounts and certificates
lego_user lego User to run Lego as
lego_group lego Group to run Lego as
lego_domains [] Domains to get certs for, see example
lego_provisioning_synced true Delete renew hooks which are no longer defined
lego_deploy_hooks [] Hooks to run after renewing, see example

Dependencies

None.

Example Playbook

---

- hosts: all
  become: true
  gather_facts: true
  roles:
    - role: lego
      vars:
        lego_domains:
          - name: "example.com"
            email: you@example.com
            dns: rfc2136
            env:
              RFC2136_NAMESERVER: 127.0.0.1
              RFC2136_TSIG_KEY: lego
              RFC2136_TSIG_ALGORITHM: hmac-sha256.
              RFC2136_TSIG_SECRET: YWJjZGVmZGdoaWprbG1ub3BxcnN0dXZ3eHl6MTIzNDU=
        lego_deploy_hooks:
          # Hooks prefixed with sudo run as root
          - name: sudo-restart-nginx
            content: |
              #!/bin/sh
              echo "I am root"
              systemctl restart nginx
          # Anything else runs as lego user
          - name: something-else
            content: |
              #!/bin/sh
              echo "I am not root"

Authors

Andrei Costescu with modifications by Pavel Valach