-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for certbot and Let's Encrypt certificates #125
base: master
Are you sure you want to change the base?
Conversation
This is a great idea, but we need to 1) make it optional, 2) document it in the ansible playbook docs (not just training) and 3) make it as close to foolproof as possible. To make it optional, I suggest revising the "when" on the role operation to check the value of some new default variable like Regarding making it foolproof: We need to have the certificate renewal also restart nginx if needed. Otherwise, this isn't really complete. I have some code that does this that I'll take a look at for possible inclusion. It may not be compatible with Geerling's approach. It would also be great if we could figure out how to activate it for a host with just an entry in webserver_virtualhosts -- rather than having separate entries in webserver_virtualhosts and certbot_certs. Again, I don't know if this is compatible with Geerling's role. |
I can make the requested revisions. Why close the PR? |
Closing was accidental. I meant to just comment. |
I wonder if it wouldn't be better to separate the certbot operations into a separate playbook. This could be modeled on the firewall.yml playbook and could use the local-configure.yml file in the same way to pick up needed variables. This would loose the coupling and help make it clear to the sysadmin that there are a variety of considerations to be taken into account in employing certbot. |
I see no need for a separate 'lets_encrypt_certificate' variable. (Perhaps I'm missing something.) Wouldn't the existing 'certificate_file' and 'key_file' options for a webserver_virtualhosts item do just as well? That's what I've been using already with my own certbot setup. If that would work, that's one less option to be separately documented and maintained. And, no code changes needed in the nginx mode. |
If the last two comments are adopted, then I think the right way to document the letsencrypt support would be in an added doc in docs. An example in the training docs is also a great idea, of course. Thanks! |
TASK [Fail if Ansible is old] ***************************************************************************************************************************************************************************************************************************************** fatal: [example.com]: FAILED! => {"msg": "The conditional check 'ansible_version is version('2.5.0', 'lt')' failed. The error was: Version comparison: '<' not supported between instances of 'str' and 'int'\n\nThe error appears to be in '/project-path/plone/ansible-playbook/playbook.yml': line 11, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: Fail if Ansible is old\n ^ here\n"}
That makes sense, especially considering the step to stop and start the web server so that certbot can run its own server to generate the first-time cert. There's a few more things going on, too.
This was in consideration to continue supporting copying certificates. When certbot installed the LE cert, it warned me not to move them, and I don't know if copying would be harmful. I used the variable From the README:
Anyway, I tried your suggestion, but it failed. These are symlinks to the actual files.
How do you manage the certbot certs? |
Certbot can handle that and with the standalone option:
So this example value can go in the certbot_auto_renew_options: '--quiet --no-self-upgrade
--pre-hook "service nginx stop" --post-hook "service nginx start"' I think I got it, but there might be a chicken-and-egg problem with restarting nginx. I have not verified yet on a clean machine, but here are my assumptions:
Here's the process outline, after a VM is setup and has a non-root user. Would you please review and let me know whether I should change it? I'm a hack at this Ansible stuff.
Commits and PRs coming shortly. |
- Add optional geerlingguy.certbot.yml playbook
Updated plone/training#470 I added docs in @smcmahon ready for review. I will test this out later tonight on a clean Digital Ocean VM. |
I tried this out on a clean DO VM, but I had to manually stop nginx, run the command to create the cert, and restart nginx. I don't know why the role |
Why, yes, there is a debug method for Ansible. I realized that defaults in the role were not getting overridden by those in my I have to do more revisions to this PR, so please hold off merging until I can finish testing. |
Fixes issue #127
I've hit a roadblock, and I don't know how to fix it. Varnish returns an error message:
I'm using Python 3 in my RUN 1
RUN 2The previous issue seems to be resolved, but the next one crops up.
This appears to be an Python 3 incompatibility. https://github.com/zopefoundation/zc.monitor/blob/master/src/zc/monitor/__init__.py#L59 Should be: except Exception as v: I tried editing my server's copy of that file, and running the playbook one more time, but that had no affect on Varnish. I have been able to reliably reproduce this issue on clean DO VMs. Can anyone point me in the right direction to troubleshoot this further? |
As a sanity check, I dropped back to Python 2 for the install, and there was no Varnish error. I submitted a PR for the |
- Add optional geerlingguy.certbot.yml playbook
- These variables were not loading as I expected from the local-configure.yml, so I moved them to where they will load. - Update webserver docs
2 months after setting up a new Plone instance with this configuration, auto renewal fails.
I don't want to go in manually every 3 months to stop nginx, run certbot, and restart nginx. How do other folks handle letsencrypt automatic renewal? |
Personally, I have this in
|
@fulv I tried running the command you have in cron, but it returns the same error message. Do you have the standalone version of certbot? I scoured letsencrypt's community for answers, but all I found was to manually stop the webserver so that certbot could then bind to port 80 and renew the certificate. |
@stevepiercy that's also what we do. We have a playbook that
a bit clunky and not 100% uptime, but kinda works. |
@polyester I'm in the same boat. No DNS hooks for LE. I'm using nginx, per the defaults of this playbook. Can you share a sanitized version of your playbook? It sounds like you still need to manually run it once per quarter, though, but at least it would save a few manual steps. I can deal with that. |
@stevepiercy it really is the simplest playbook, basically
which isn't very refined. Our ansible master is cronnable, but if you have to run it manually of course that is prone to forgetting. Maybe for the playbook having the cronjob on the target do the "stop nginx, renew certificate, start nginx" would be sufficient? (although of course Ansible complains louder and better if for whatever reason nginx doesn't come up again...) |
I use the nginx version of certbot.
--
Fulvio
…On Thu, Jan 16, 2020 at 5:28 AM Paul Roeland ***@***.***> wrote:
@stevepiercy <https://github.com/stevepiercy> it really is the simplest
playbook, basically
- name: stop nginx service
service: name=nginx state=stopped
- name: renew cert
command: certbot renew
- name: start nginx service
service: name=nginx state=started
which isn't very refined. Our ansible master is cronnable, but if you have
to run it manually of course that is prone to forgetting. Maybe for the
playbook having the cronjob on the target do the "stop nginx, renew
certificate, start nginx" would be sufficient? *(although of course
Ansible complains louder and better if for whatever reason nginx doesn't
come up again...)*
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#125?email_source=notifications&email_token=AADQPRTZJQVIGPOMEGUX6MLQ6BOI3A5CNFSM4JNRZWD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJEBXUQ#issuecomment-575151058>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADQPRXF77USJ7CV5BKNX33Q6BOI3ANCNFSM4JNRZWDQ>
.
|
I have https://mailinabox.email running and it renews the certs without my quasi-human intervention, if you're looking for possible examples |
@tkimnguyen yes, please! I still haven't figured this one out. |
@tkimnguyen reping. I'd like to see your example. |
@stevepiercy this is what the certbot docs say about not stopping the webserver during the certificate issuance process: https://certbot.eff.org/docs/using.html#webroot |
@tkimnguyen how do you use the webroot option with Plone? I can't figure out the value for |
The current version of the certbot-nginx plugin is supposedly capable of issuing and renewing with no downtime. There's a discussion of how this is done in the thread at: https://certbot.eff.org/faq#can-i-issue-a-certificate-without-bringing-down-my-web-server with some supplementary information from nginx at: https://www.nginx.com/faq/how-does-zero-downtime-configuration-testingreload-in-nginx-plus-work/ If this is acceptable, that plugin makes things dead simple. I've tried it out in a branch: https://github.com/plone/ansible-playbook/tree/simplified-certbot See https://github.com/plone/ansible-playbook/blob/simplified-certbot/docs/certbot.rst for quick documentation. |
@smcmahon I checked out that branch, and added an entry to my
I then commented out I found that when I ssh in, and issue the command I pushed a commit with some suggested changes. Thanks for doing the legwork on this! |
I also added a cron job to automatically attempt to renew the certificates in f0cc209 |
Smoke test: I tried adding, renewing and revoking certificates on a host using the certbot-nginx plugin while simultaneously hitting a static site with 100,000 sequential ab requests. I saw no failed requests and no latency greater than 10 ms. |
No cronjob is needed; the certbot-nginx package creates its own with a randomized run time. I've created a pull request for the "simplified certbot" branch with stevepiercy's other changes. |
@smcmahon where is that cronjob? I didn't see it on my server for any user in |
/etc/cron.d/certbot |
Merge or drop? |
@jensens I don't know. I assume it is still useful to someone, but I lack the bandwidth to follow through. Anyone else is welcome to take it over. |
Closes #61.
See related documentation update in plone/training#470.