Skip to content
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

Certbot support using certbot nginx plugin #136

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

smcmahon
Copy link
Member

Simplifies using playbook to issue and use LetsEncrypt certificates.

Copy link
Contributor

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at my questions and comments. Thank you!

Then it will create certificates as necessary for each hostname in the ``certbot_hosts`` list.
If a certificate already exists, it will not attempt addition.

Note that ``python3-certbot-nginx`` includes an auto-renewal cronjob.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not see this on my server in /var/spool/cron/crontabs/ after running the playbook. Where is it located?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/cron.d/certbot

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

I note that the cron job does not include --nginx flag for certbot -q renew. I guess we will find out if it works for me on May 12 when my current cert is due to expire.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto-renew cronjob failed. See #136 (comment)


ansible-playbook -k certbot.yml

This will first install ``python3-certbot-nginx`` from the certbot/certbot ppa.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's "ppa"? Is there a link to it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal Package Archive; standard debian mechanism for maintaining an additional package source. In this case, it's certbot's.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This will first install ``python3-certbot-nginx`` from the certbot/certbot ppa.
This will first install ``python3-certbot-nginx`` from the certbot/certbot Personal Package Archive.

docs/certbot.rst Outdated Show resolved Hide resolved
docs/webserver.rst Outdated Show resolved Hide resolved
@stevepiercy
Copy link
Contributor

With that one new suggestion, I'm OK with merging this. Maybe someone else has an older cert they can test for renewal?

@stevepiercy
Copy link
Contributor

Well, the automatic renewal did not work on my system:

2020-05-12 06:26:19,263:DEBUG:acme.standalone:Failed to bind to :80 using IPv6
2020-05-12 06:26:19,263:DEBUG:acme.standalone:Failed to bind to :80 using IPv4

Is there something I should check?

$ sudo cat /etc/cron.d/certbot
# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc.  Renewal will only occur if expiration
# is within 30 days.
#
# Important Note!  This cronjob will NOT be executed if you are
# running systemd as your init system.  If you are running systemd,
# the cronjob.timer function takes precedence over this cronjob.  For
# more details, see the systemd.timer manpage, or use systemctl show
# certbot.timer.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

@fulv
Copy link
Member

fulv commented May 13, 2020

Try running /usr/bin/certbot renew manually and see what error it gives you.

I don't understand what that cron job does. This is what I have:

@monthly /usr/bin/certbot renew --post-hook "service nginx restart"

@stevepiercy
Copy link
Contributor

I expect the manual invocation of /usr/bin/certbot renew to work. I haven't tried it.

Maybe we should change the cronjob that python3-certbot-nginx creates to your version?

@smcmahon
Copy link
Member Author

I wonder if there's any chance that stevepiercy has a combination of the nginx and standalone versions of certbot installed on a test machine. The "failed to bind" error would indicate that certbot tried to use its standalone web server without knowledge of the nginx install.

@stevepiercy
Copy link
Contributor

Yes, I did install standalone originally on this machine.

I think that --nginx must be included in the cronjob command. That cronjob comes from the package python3-certbot-nginx, right? If so, what would be the best option to resolve the issue?

@fulv
Copy link
Member

fulv commented May 14, 2020

I found that this probably depends on the [renewalparams] / authenticator value in the /etc/letsencrypt/renewal/yourdomain.conf file. In my case, authenticator = nginx, and also installer = nginx, which was probably set when I first ran certbot (which was manual, not via ansible). But yeah, the first time it needs to be run with --nginx.

@stevepiercy
Copy link
Contributor

Aye, there she is!

authenticator = standalone

The next time I deploy another Plone instance (which could be next week) I will check my /etc/letsencrypt/renewal/<site>.conf. Has anyone else done a clean install with this branch, and can check theirs? I think this bit was the only thing holding up the merge of this PR.

@smcmahon
Copy link
Member Author

smcmahon commented May 14, 2020

Some bad news: the nginx certbot plugin is not working with Ubuntu 20.04 (focal). Looks like the bug's been reported and is fixable, but we'll want to wait for that fix before considering this as supported on Focal. certbot/certbot#7951

@stevepiercy
Copy link
Contributor

I did some digging, and it looks like a release with the fix is imminent.

@stevepiercy
Copy link
Contributor

@stevepiercy
Copy link
Contributor

@smcmahon ping. Would you please rebase on master, merge HISTORY.txt, and push?

@tkimnguyen
Copy link
Member

I can take a look at this on the weekend if no one else does before

@smcmahon
Copy link
Member Author

smcmahon commented Jul 8, 2020

Rebased with master. certbot.yml test passes on bionic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants