Skip to content

Commit

Permalink
Merge pull request coopdevs#12 from coopdevs/update_README_multiple_c…
Browse files Browse the repository at this point in the history
…ertificates

Update the README with the multiple certificates creation information
  • Loading branch information
enricostano authored May 16, 2019
2 parents c21618b + e48a9c1 commit 97b2d03
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This role will:
1. Add `certbot` PPA repository
2. Install `certbot` and `python-certbot-nginx` packages
3. `certbot` package will add a `renew` cron job and a systemd-timer ([More info](https://certbot.eff.org/#ubuntuxenial-nginx)
4. Generate a Let's Encrypt SSL certificate for the given `domain_name`
4. Generate a Let's Encrypt SSL certificates for the given `domain_name`.

Role Variables
--------------
Expand All @@ -21,19 +21,55 @@ certbot_nginx_version: 0.31.0-1+ubuntu{{ ansible_distribution_version }}.1+certb
if set, `certbot_nginx_cert_name`'s value will be passed to the certbot's `--cert-name` argument, which is used to identify the certificate in certbot command such as `certbot delete`. You will see a list of certificates identified with this name by running `certbot certificates`. This name will also be used as the file paths for the certificate in `/etc/letsencrypt/live/`.

Example Playbook
----------------
Example Playbook - Single certificate
-------------------------------------

```yaml
# Playbook
- hosts: servers
roles:
- role: coopdevs.certbot_nginx
vars:
domain_name: www.mydomain.io
letsencrypt_email: [email protected]
certbot_nginx_cert_name: mycert
```

Example Playbook - Multiple certificates creation
-------------------------------------------------

Also allow to generate and manage multiple certificates in the same host.
You can define the var `domain_names` and configure a role to incude the this role in a loop.

```yaml
# Playbook
- hosts: servers
roles:
- role: coopdevs.certbot_nginx
vars:
letsencrypt_email: [email protected]
- role: certificates
vars:
domain_names:
- community.coopdevs.org
- forms.coopdevs.org
```

Create a custom role including the `certbot_nginx` role that generates the certificates:

```yaml
# certificates.yml Role
---
- name: Install SSL certificates
include_role:
name: vendor/coopdevs.certbot_nginx
tasks_from: certificate.yml
with_items: "{{ domain_names }}"
loop_control:
loop_var: domain_name
```

> You need to declare the `loop_control` to map the `item` var of the `with_item` loop with the `loop_var` value as `domain_name`. See the [`loop_controll` doc](https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html?highlight=loop_control#loop-control)

Let's Encrypt Staging Environment
---------------------------------

Expand Down

0 comments on commit 97b2d03

Please sign in to comment.