-
-
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
Certbot support using certbot nginx plugin #136
base: master
Are you sure you want to change the base?
Changes from all commits
7e2adf9
82b2d49
bd4f1c2
9112ebb
605db56
f0cc209
be7c117
227c09d
7ab6ee3
97310a1
98fb7a1
f050e98
a45ec6e
3c2b203
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Certbot options | ||
``````````````` | ||
|
||
The certbot playbook | ||
~~~~~~~~~~~~~~~~~~~~ | ||
|
||
As a convenience, the Plone Ansible Playbook kit includes a separate | ||
playbook that will install certbot-nginx and create certificates as necessary for specified hostnames. | ||
|
||
The certbot playbook currently only supports Debian-family target servers. | ||
|
||
To use the certbot playbook, edit your ``local-configure.yml`` file to add a ``certbot_hosts`` list variable containing an entry for each hostname for which you wish to get a certbot certificate: | ||
|
||
.. code-block:: yaml | ||
|
||
certbot_hosts: | ||
- one.mcsmith.org | ||
- two.mcsmith.org | ||
|
||
Run the playbook as you would the main playbook, adding whatever command-line switches you need (like ``-k`` or ``-K``): | ||
|
||
.. code-block:: console | ||
|
||
ansible-playbook -k certbot.yml | ||
|
||
This will first install ``python3-certbot-nginx`` from the certbot/certbot ppa. | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not see this on my server in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /etc/cron.d/certbot There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The auto-renew cronjob failed. See #136 (comment) |
||
|
||
|
||
Webserver support | ||
~~~~~~~~~~~~~~~~~ | ||
|
||
When the nginx role creates a configuration file for a virtual host, it will check TLS hostnames against the ``certbot_hosts`` list. | ||
If the hostname matches, the certbot certificate/key will be used automatically (unless you override this by specifying certificate/key files). | ||
|
||
Certificate/key files for certbot are expected to be in ``/etc/letsencrypt/live/HOST_NAME`` or this mechanism will fail when nginx is reloaded after configuration. | ||
|
||
|
||
Why is this a separate playbook? | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
As with the ``firewall.yml`` playbook, we want to encourage users to think and research before using the certbot playbook. | ||
*Let's Encrypt* is security software and is not for everyone. | ||
It should be used only with knowledge and deliberation and not as an autopilot choice. | ||
|
||
Note in particular that the certbot-nginx support uses root priveleges for both certificate creation and renewal. | ||
Some sysadmins choosing certbot may wish to set up their own creation/renewal systems to avoid this exposure. | ||
|
||
Note that even if you never run the certbot playbook, you may still find the webserver setup support useful. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ Plone's Ansible Playbook | |
multiserver | ||
restart_script | ||
audit | ||
certbot |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
------------------------------------------ | ||
Test the certbot playbook for provisioning | ||
------------------------------------------ | ||
>>> sample = 'sample-medium.yml' | ||
|
||
>>> extras = r""" | ||
... admin_email: [email protected] | ||
... plone_initial_password: admin | ||
... additional_packages: | ||
... - curl | ||
... - lsof | ||
... muninnode_query_ips: | ||
... - 127.0.0.1 | ||
... certbot_hosts: [] | ||
... """ | ||
|
||
>>> import subprocess | ||
>>> import sys | ||
>>> import time | ||
|
||
Set up local-configure.yml by copying our sample. | ||
Append extras. | ||
|
||
>>> with open(sample, 'r') as f: | ||
... with open('local-configure.yml', 'w') as g: | ||
... g.write(f.read() + extras) | ||
|
||
Vagrant up | ||
|
||
>>> print >> sys.stderr, "Bringing up %s" % box | ||
>>> run("vagrant up %s --provision-with write_vbox_cfg" % box) | ||
|
||
Vagrant provision -- unless contraindicated. | ||
|
||
>>> if skip_provisioning: | ||
... print >> sys.stderr, "Skipping provisioning" | ||
... else: | ||
... print >> sys.stderr, "Provisioning" | ||
... run("ansible-playbook -i vbox_host.cfg certbot.yml") | ||
|
||
|
||
And, now run tests against the box. | ||
|
||
>>> print >> sys.stderr, "Running tests against box" | ||
|
||
Check hostname: | ||
|
||
>>> ssh_run('which certbot').strip() | ||
'/usr/bin/certbot' | ||
|
||
>>> ssh_run('ls -d /etc/letsencrypt').strip() | ||
'/etc/letsencrypt' | ||
|
||
>>> ssh_run('certbot --help | grep "\--nginx"') | ||
' --nginx Use the Nginx plugin for authentication & installation\r\n' | ||
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.