{"id":13588166,"url":"https://github.com/geerlingguy/ansible-role-certbot","last_synced_at":"2025-05-14T19:05:34.583Z","repository":{"id":37561564,"uuid":"53428883","full_name":"geerlingguy/ansible-role-certbot","owner":"geerlingguy","description":"Ansible Role - Certbot (for Let's Encrypt)","archived":false,"fork":false,"pushed_at":"2025-03-25T14:19:51.000Z","size":135,"stargazers_count":818,"open_issues_count":11,"forks_count":355,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-06T09:03:22.491Z","etag":null,"topics":["ansible","certbot","certificate","https","letsencrypt","role","ssl"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/geerlingguy/certbot/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geerlingguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"geerlingguy","patreon":"geerlingguy"}},"created_at":"2016-03-08T16:49:38.000Z","updated_at":"2025-04-01T01:51:17.000Z","dependencies_parsed_at":"2025-01-03T10:02:30.711Z","dependency_job_id":"849aab70-b02f-446a-bdb0-acefd623351a","html_url":"https://github.com/geerlingguy/ansible-role-certbot","commit_stats":{"total_commits":142,"total_committers":22,"mean_commits":6.454545454545454,"dds":0.3802816901408451,"last_synced_commit":"98ea3238ed399a0b8c6a974e7259f01a79b5fcde"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-certbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-certbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-certbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geerlingguy%2Fansible-role-certbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geerlingguy","download_url":"https://codeload.github.com/geerlingguy/ansible-role-certbot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248717240,"owners_count":21150387,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","certbot","certificate","https","letsencrypt","role","ssl"],"created_at":"2024-08-01T15:06:32.786Z","updated_at":"2025-04-13T12:45:53.774Z","avatar_url":"https://github.com/geerlingguy.png","language":"Shell","funding_links":["https://github.com/sponsors/geerlingguy","https://patreon.com/geerlingguy"],"categories":["Shell","ssl"],"sub_categories":[],"readme":"# Ansible Role: Certbot (for Let's Encrypt)\n\n[![CI](https://github.com/geerlingguy/ansible-role-certbot/actions/workflows/ci.yml/badge.svg)](https://github.com/geerlingguy/ansible-role-certbot/actions/workflows/ci.yml)\n\nInstalls and configures Certbot (for Let's Encrypt).\n\n## Requirements\n\nIf installing from source, Git is required. You can install Git using the `geerlingguy.git` role.\n\nGenerally, installing from source (see section `Source Installation from Git`) leads to a better experience using Certbot and Let's Encrypt, especially if you're using an older OS release.\n\n## Role Variables\n\n    certbot_install_method: package\n\nControls how Certbot is installed. Available options are 'package', 'snap', and 'source'.\n\n    certbot_auto_renew: true\n    certbot_auto_renew_user: \"{{ ansible_user | default(lookup('env', 'USER')) }}\"\n    certbot_auto_renew_hour: \"3\"\n    certbot_auto_renew_minute: \"30\"\n    certbot_auto_renew_options: \"--quiet\"\n\nBy default, this role configures a cron job to run under the provided user account at the given hour and minute, every day. The defaults run `certbot renew` (or `certbot-auto renew`) via cron every day at 03:30:00 by the user you use in your Ansible playbook. It's preferred that you set a custom user/hour/minute so the renewal is during a low-traffic period and done by a non-root user account.\n\n### Automatic Certificate Generation\n\nCurrently the `standalone` and `webroot` method are supported for generating new certificates using this role.\n\n**For a complete example**: see the fully functional test playbook in [molecule/default/playbook-standalone-nginx-aws.yml](molecule/default/playbook-standalone-nginx-aws.yml).\n\n    certbot_create_if_missing: false\n\nSet `certbot_create_if_missing` to `yes` or `True` to let this role generate certs. \n\n    certbot_create_method: standalone\n\nSet the method used for generating certs with the `certbot_create_method` variable — current allowed values are: `standalone` or `webroot`.\n\n    certbot_testmode: false\n\nEnable test mode to only run a test request without actually creating certificates.\n\n    certbot_hsts: false\n\nEnable (HTTP Strict Transport Security) for the certificate generation.\n\n    certbot_admin_email: email@example.com\n\nThe email address used to agree to Let's Encrypt's TOS and subscribe to cert-related notifications. This should be customized and set to an email address that you or your organization regularly monitors.\n\n    certbot_certs: []\n      # - email: janedoe@example.com\n      #   webroot: \"/var/www/html\"\n      #   domains:\n      #     - example1.com\n      #     - example2.com\n      # - domains:\n      #     - example3.com\n\nA list of domains (and other data) for which certs should be generated. You can add an `email` key to any list item to override the `certbot_admin_email`. When using the `webroot` creation method, a `webroot` item has to be provided, specifying which directory to use for the authentication. Make sure your webserver correctly delivers contents from this directory.\n\n    certbot_create_command: \"{{ certbot_script }} certonly --standalone --noninteractive --agree-tos --email {{ cert_item.email | default(certbot_admin_email) }} -d {{ cert_item.domains | join(',') }}\"\n\nThe `certbot_create_command` defines the command used to generate the cert. See the full default command inside `defaults/main.yml` for a full example—and you can easily add in extra arguments that are not in the default command with the `certbot_create_extra_args` variable.\n\n#### Standalone Certificate Generation\n\n    certbot_create_standalone_stop_services:\n      - nginx\n\nServices that should be stopped while `certbot` runs it's own standalone server on ports 80 and 443. If you're running Apache, set this to `apache2` (Ubuntu), or `httpd` (RHEL), or if you have Nginx on port 443 and something else on port 80 (e.g. Varnish, a Java app, or something else), add it to the list so it is stopped when the certificate is generated.\n\nThese services will only be stopped the first time a new cert is generated.\n\n### Snap Installation\n\nBeginning in December 2020, the Certbot maintainers decided to recommend installing Certbot from Snap rather than maintain scripts like `certbot-auto`.\n\nSetting `certbot_install_method: snap` configures this role to install Certbot via Snap.\n\nThis install method is currently experimental and may or may not work across all Linux distributions.\n\n#### Webroot Certificate Generation\n\nWhen using the `webroot` creation method, a `webroot` item has to be provided for every `certbot_certs` item, specifying which directory to use for the authentication. Also, make sure your webserver correctly delivers contents from this directory.\n\n### Source Installation from Git\n\nYou can install Certbot from it's Git source repository if desired with `certbot_install_method: source`. This might be useful in several cases, but especially when older distributions don't have Certbot packages available (e.g. CentOS \u003c 7, Ubuntu \u003c 16.10 and Debian \u003c 8).\n\n    certbot_repo: https://github.com/certbot/certbot.git\n    certbot_version: master\n    certbot_keep_updated: true\n\nCertbot Git repository options. If installing from source, the configured `certbot_repo` is cloned, respecting the `certbot_version` setting. If `certbot_keep_updated` is set to `yes`, the repository is updated every time this role runs.\n\n    certbot_dir: /opt/certbot\n\nThe directory inside which Certbot will be cloned.\n\n### Wildcard Certificates\n\nLet's Encrypt supports [generating wildcard certificates](https://community.letsencrypt.org/t/acme-v2-and-wildcard-certificate-support-is-live/55579), but the process for generating and using them is slightly more involved. See comments in [this pull request](https://github.com/geerlingguy/ansible-role-certbot/pull/60#issuecomment-423919284) for an example of how to use this role to maintain wildcard certs.\n\nMichael Porter also has a walkthrough of [Creating A Let’s Encrypt Wildcard Cert With Ansible](https://www.michaelpporter.com/2018/09/creating-a-wildcard-cert-with-ansible/), specifically with Cloudflare.\n\n## Dependencies\n\nNone.\n\n## Example Playbook\n\n    - hosts: servers\n    \n      vars:\n        certbot_auto_renew_user: your_username_here\n        certbot_auto_renew_minute: \"20\"\n        certbot_auto_renew_hour: \"5\"\n    \n      roles:\n        - geerlingguy.certbot\n\nSee other examples in the `tests/` directory.\n\n### Manually creating certificates with certbot\n\n_Note: You can have this role automatically generate certificates; see the \"Automatic Certificate Generation\" documentation above._\n\nYou can manually create certificates using the `certbot` (or `certbot-auto`) script (use `letsencrypt` on Ubuntu 16.04, or use `/opt/certbot/certbot-auto` if installing from source/Git. Here are some example commands to configure certificates with Certbot:\n\n    # Automatically add certs for all Apache virtualhosts (use with caution!).\n    certbot --apache\n\n    # Generate certs, but don't modify Apache configuration (safer).\n    certbot --apache certonly\n\nIf you want to fully automate the process of adding a new certificate, but don't want to use this role's built in functionality, you can do so using the command line options to register, accept the terms of service, and then generate a cert using the standalone server:\n\n  1. Make sure any services listening on ports 80 and 443 (Apache, Nginx, Varnish, etc.) are stopped.\n  2. Register with something like `certbot register --agree-tos --email [your-email@example.com]`\n    - Note: You won't need to do this step in the future, when generating additional certs on the same server.\n  3. Generate a cert for a domain whose DNS points to this server: `certbot certonly --noninteractive --standalone -d example.com -d www.example.com`\n  4. Re-start whatever was listening on ports 80 and 443 before.\n  5. Update your webserver's virtualhost TLS configuration to point at the new certificate (`fullchain.pem`) and private key (`privkey.pem`) Certbot just generated for the domain you passed in the `certbot` command.\n  6. Reload or restart your webserver so it uses the new HTTPS virtualhost configuration.\n\n### Certbot certificate auto-renewal\n\nBy default, this role adds a cron job that will renew all installed certificates once per day at the hour and minute of your choosing.\n\nYou can test the auto-renewal (without actually renewing the cert) with the command:\n\n    /opt/certbot/certbot-auto renew --dry-run\n\nSee full documentation and options on the [Certbot website](https://certbot.eff.org/).\n\n## License\n\nMIT / BSD\n\n## Author Information\n\nThis role was created in 2016 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fansible-role-certbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeerlingguy%2Fansible-role-certbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeerlingguy%2Fansible-role-certbot/lists"}