mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2026-08-22 07:50:43 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
222d57cb2e | ||
|
|
7c8e2e5735 | ||
|
|
b5ff8d4886 | ||
|
|
bca9164582 | ||
|
|
353747a915 | ||
|
|
d76e3915fe | ||
|
|
a2f63847fd | ||
|
|
18e2752f0e | ||
|
|
ea45b22546 | ||
|
|
565678e559 | ||
|
|
c84f967a08 | ||
|
|
373fa29f60 | ||
|
|
eece6540a2 |
+12
-23
@@ -1,60 +1,49 @@
|
||||
---
|
||||
sudo: required
|
||||
services: docker
|
||||
|
||||
env:
|
||||
- repository: geerlingguy/docker-centos7-ansible
|
||||
version: latest
|
||||
- distro: centos7
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- repository: geerlingguy/docker-centos6-ansible
|
||||
version: latest
|
||||
- distro: centos6
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
- repository: geerlingguy/docker-ubuntu1604-ansible
|
||||
version: latest
|
||||
- distro: ubuntu1604
|
||||
init: /lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- repository: geerlingguy/docker-ubuntu1404-ansible
|
||||
version: latest
|
||||
- distro: ubuntu1404
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
- repository: geerlingguy/docker-ubuntu1204-ansible
|
||||
version: latest
|
||||
- distro: ubuntu1204
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
# Pull container.
|
||||
- 'sudo docker pull ${repository}:${version}'
|
||||
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
|
||||
|
||||
script:
|
||||
- container_id=$(mktemp)
|
||||
# Run container in detached state.
|
||||
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${repository}:${version} "${init}" > "${container_id}"'
|
||||
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
|
||||
|
||||
# Install dependencies.
|
||||
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
|
||||
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
|
||||
|
||||
# Ansible syntax check.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
||||
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
|
||||
|
||||
# Test role.
|
||||
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
||||
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
|
||||
|
||||
# Test role idempotence.
|
||||
- idempotence=$(mktemp)
|
||||
- sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
|
||||
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
|
||||
- >
|
||||
tail ${idempotence}
|
||||
| grep -q 'changed=0.*failed=0'
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
|
||||
# Clean up.
|
||||
- 'sudo docker stop "$(cat ${container_id})"'
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
||||
@@ -20,6 +20,13 @@ Certbot code repository options. This role clones the agent from the configured
|
||||
|
||||
The directory inside which Certbot will be cloned.
|
||||
|
||||
certbot_auto_renew: true
|
||||
certbot_auto_renew_user: "{{ ansible_user }}"
|
||||
certbot_auto_renew_hour: 3
|
||||
certbot_auto_renew_minute: 30
|
||||
|
||||
By 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-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.
|
||||
|
||||
## Dependencies
|
||||
|
||||
None.
|
||||
@@ -27,8 +34,14 @@ None.
|
||||
## Example Playbook
|
||||
|
||||
- hosts: servers
|
||||
|
||||
vars:
|
||||
certbot_auto_renew_user: your_username_here
|
||||
certbot_auto_renew_minute: 20
|
||||
certbot_auto_renew_hour: 5
|
||||
|
||||
roles:
|
||||
- geerlingguy.letsencrypt
|
||||
- geerlingguy.certbot
|
||||
|
||||
After installation, you can create certificates using the `certbot-auto` script, which by default is installed inside the configured `certbot_dir`, so by default, `/opt/certbot/certbot-auto`. Here are some example commands to configure certificates with Certbot:
|
||||
|
||||
@@ -38,9 +51,7 @@ After installation, you can create certificates using the `certbot-auto` script,
|
||||
# Generate certs, but don't modify Apache configuration (safer).
|
||||
/opt/certbot/certbot-auto --apache certonly
|
||||
|
||||
To set up renewals, you should run the following command periodically (e.g. once or twice per day):
|
||||
|
||||
/opt/certbot/certbot-auto renew --quiet --no-self-upgrade
|
||||
By default, this role adds a cron job that will renew all installed certificates once per day at the hour and minute of your choosing.
|
||||
|
||||
You can test the auto-renewal (without actually renewing the cert) with the command:
|
||||
|
||||
@@ -54,4 +65,4 @@ MIT / BSD
|
||||
|
||||
## Author Information
|
||||
|
||||
This role was created in 2016 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
|
||||
This role was created in 2016 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
---
|
||||
# Where to get Certbot.
|
||||
certbot_repo: https://github.com/certbot/certbot.git
|
||||
certbot_version: master
|
||||
certbot_keep_updated: yes
|
||||
|
||||
# Where to put Certbot.
|
||||
certbot_dir: /opt/certbot
|
||||
|
||||
# How to keep Certbot certs up to date.
|
||||
certbot_auto_renew: true
|
||||
certbot_auto_renew_user: "{{ ansible_user }}"
|
||||
certbot_auto_renew_hour: 3
|
||||
certbot_auto_renew_minute: 30
|
||||
|
||||
@@ -22,3 +22,9 @@ galaxy_info:
|
||||
- networking
|
||||
- system
|
||||
- web
|
||||
- certbot
|
||||
- letsencrypt
|
||||
- encryption
|
||||
- certificates
|
||||
- ssl
|
||||
- https
|
||||
|
||||
@@ -10,3 +10,12 @@
|
||||
file:
|
||||
path: "{{ certbot_dir }}/certbot-auto"
|
||||
mode: 0755
|
||||
|
||||
- name: Add cron job for 'certbot-auto renew' (if configured).
|
||||
cron:
|
||||
name: Certbot automatic renewal.
|
||||
job: "{{ certbot_dir }}/certbot-auto renew --quiet --no-self-upgrade"
|
||||
minute: "{{ certbot_auto_renew_minute }}"
|
||||
hour: "{{ certbot_auto_renew_hour }}"
|
||||
user: "{{ certbot_auto_renew_user }}"
|
||||
when: certbot_auto_renew
|
||||
|
||||
+11
-2
@@ -3,8 +3,17 @@
|
||||
|
||||
pre_tasks:
|
||||
- name: Update apt cache.
|
||||
apt: update_cache=yes
|
||||
when: ansible_distribution == 'Ubuntu'
|
||||
apt: update_cache=yes cache_valid_time=600
|
||||
when: ansible_os_family == 'Debian'
|
||||
changed_when: false
|
||||
|
||||
- name: Install cron (RedHat).
|
||||
yum: name=cronie state=present
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
- name: Install cron (Debian).
|
||||
apt: name=cron state=present
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
roles:
|
||||
- geerlingguy.git
|
||||
|
||||
Reference in New Issue
Block a user