mirror of
https://github.com/geerlingguy/ansible-role-certbot.git
synced 2026-08-22 07:50:43 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01d801c4b7 | ||
|
|
3b47bfb39e | ||
|
|
da3ad13935 | ||
|
|
932214698b | ||
|
|
2f8a0f06d5 | ||
|
|
24d40c7b10 | ||
|
|
1ca3e00b46 | ||
|
|
065d889858 | ||
|
|
da5a6738d5 | ||
|
|
e82a68e331 | ||
|
|
92ef96faff | ||
|
|
c82468099b | ||
|
|
1f89316182 | ||
|
|
141dd08882 | ||
|
|
ef18833af5 | ||
|
|
afa993333f | ||
|
|
33724b0a93 | ||
|
|
b82eeeed79 | ||
|
|
f3a260e94e | ||
|
|
35ceee9f1b | ||
|
|
3dedd45961 | ||
|
|
806d612fab | ||
|
|
52dbc87e22 |
@@ -0,0 +1,2 @@
|
||||
*.retry
|
||||
tests/test.sh
|
||||
+9
-35
@@ -3,47 +3,21 @@ services: docker
|
||||
|
||||
env:
|
||||
- distro: centos7
|
||||
init: /usr/lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- distro: centos6
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
playbook: test-source-install.yml
|
||||
- distro: ubuntu1604
|
||||
init: /lib/systemd/systemd
|
||||
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
|
||||
- distro: ubuntu1404
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
- distro: ubuntu1204
|
||||
init: /sbin/init
|
||||
run_opts: ""
|
||||
|
||||
before_install:
|
||||
# Pull container.
|
||||
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
|
||||
playbook: test-source-install.yml
|
||||
- distro: debian8
|
||||
playbook: test-source-install.yml
|
||||
|
||||
script:
|
||||
- container_id=$(mktemp)
|
||||
# Run container in detached state.
|
||||
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
|
||||
# Download test shim.
|
||||
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
|
||||
- chmod +x ${PWD}/tests/test.sh
|
||||
|
||||
# Install dependencies.
|
||||
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
|
||||
|
||||
# Ansible 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.
|
||||
- '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)
|
||||
- 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)
|
||||
# Run tests.
|
||||
- ${PWD}/tests/test.sh
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Jeff Geerling
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -2,30 +2,37 @@
|
||||
|
||||
[](https://travis-ci.org/geerlingguy/ansible-role-certbot)
|
||||
|
||||
Installs Certbot (for Let's Encrypt) for RHEL/CentOS or Debian/Ubuntu.
|
||||
Installs and configures Certbot (for Let's Encrypt).
|
||||
|
||||
## Requirements
|
||||
|
||||
Certbot requires Git to be installed. You can install Git using the `geerlingguy.git` role.
|
||||
If installing from source, Git is required. You can install Git using the `geerlingguy.git` role.
|
||||
|
||||
## Role Variables
|
||||
|
||||
certbot_repo: https://github.com/certbot/certbot.git
|
||||
certbot_version: master
|
||||
certbot_keep_updated: yes
|
||||
|
||||
Certbot code repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable.
|
||||
|
||||
certbot_dir: /opt/certbot
|
||||
|
||||
The directory inside which Certbot will be cloned.
|
||||
The variable `certbot_install_from_source` controls whether to install Certbot from Git or package management. The latter is the default, so the variable defaults to `no`.
|
||||
|
||||
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.
|
||||
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 renew` (or `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.
|
||||
|
||||
### Source Installation from Git
|
||||
|
||||
You can install Certbot from it's Git source repository if desired. This might be useful in several cases, but especially when older distributions don't have Certbot packages available (e.g. CentOS < 7, Ubuntu < 16.10 and Debian < 8).
|
||||
|
||||
certbot_install_from_source: no
|
||||
certbot_repo: https://github.com/certbot/certbot.git
|
||||
certbot_version: master
|
||||
certbot_keep_updated: yes
|
||||
|
||||
Certbot Git repository options. To install from source, set `certbot_install_from_source` to `yes`. This clones the configured `certbot_repo`, respecting the `certbot_version` setting. If `certbot_keep_updated` is set to `yes`, the repository is updated every time this role runs.
|
||||
|
||||
certbot_dir: /opt/certbot
|
||||
|
||||
The directory inside which Certbot will be cloned.
|
||||
|
||||
## Dependencies
|
||||
|
||||
@@ -43,11 +50,11 @@ None.
|
||||
roles:
|
||||
- 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:
|
||||
After installation, you can create certificates using the `certbot` (or `certbot-auto`) script, which by default is installed inside the configured `certbot_dir` (when using Git). Here are some example commands to configure certificates with Certbot:
|
||||
|
||||
# Automatically add certs for all Apache virtualhosts (use with caution!).
|
||||
/opt/certbot/certbot-auto --apache
|
||||
|
||||
|
||||
# Generate certs, but don't modify Apache configuration (safer).
|
||||
/opt/certbot/certbot-auto --apache certonly
|
||||
|
||||
@@ -65,4 +72,4 @@ MIT / BSD
|
||||
|
||||
## Author Information
|
||||
|
||||
This role was created in 2016 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
||||
This role was created in 2016 by [Jeff Geerling](https://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).
|
||||
|
||||
+11
-9
@@ -1,14 +1,16 @@
|
||||
---
|
||||
# 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 cron job configuration (for certificate renewals).
|
||||
certbot_auto_renew: true
|
||||
certbot_auto_renew_user: "{{ ansible_user }}"
|
||||
certbot_auto_renew_hour: 3
|
||||
certbot_auto_renew_minute: 30
|
||||
|
||||
# To install from source (on older OSes or if you need a specific or newer
|
||||
# version of Certbot), set this variable to `yes` and configure other options.
|
||||
certbot_install_from_source: no
|
||||
certbot_repo: https://github.com/certbot/certbot.git
|
||||
certbot_version: master
|
||||
certbot_keep_updated: yes
|
||||
|
||||
# Where to put Certbot when installing from source.
|
||||
certbot_dir: /opt/certbot
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
---
|
||||
# TODO
|
||||
+7
-4
@@ -3,21 +3,24 @@ dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: "Certbot (for Let's Encrypt) for RHEL/CentOS and Debian/Ubuntu."
|
||||
description: "Installs and configures Certbot (for Let's Encrypt)."
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 1.8
|
||||
min_ansible_version: 2.0
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 6
|
||||
- 7
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
- name: Ubuntu
|
||||
versions:
|
||||
- all
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- all
|
||||
- all
|
||||
galaxy_tags:
|
||||
- networking
|
||||
- system
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Load a variable file based on the OS type, or a default if not found.
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yml"
|
||||
- "{{ ansible_distribution }}.yml"
|
||||
- "{{ ansible_os_family }}.yml"
|
||||
- "default.yml"
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
- name: Clone Certbot into configured directory.
|
||||
git:
|
||||
repo: "{{ certbot_repo }}"
|
||||
dest: "{{ certbot_dir }}"
|
||||
version: "{{ certbot_version }}"
|
||||
update: "{{ certbot_keep_updated }}"
|
||||
force: yes
|
||||
|
||||
- name: Set Certbot script variable.
|
||||
set_fact:
|
||||
certbot_script: "{{ certbot_dir }}/certbot-auto"
|
||||
|
||||
- name: Ensure certbot-auto is executable.
|
||||
file:
|
||||
path: "{{ certbot_script }}"
|
||||
mode: 0755
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Install Certbot.
|
||||
package: "name={{ certbot_package }} state=present"
|
||||
|
||||
- name: Set Certbot script variable.
|
||||
set_fact:
|
||||
certbot_script: "{{ certbot_package }}"
|
||||
+7
-17
@@ -1,21 +1,11 @@
|
||||
---
|
||||
- name: Clone Certbot into configured directory.
|
||||
git:
|
||||
repo: "{{ certbot_repo }}"
|
||||
dest: "{{ certbot_dir }}"
|
||||
version: "{{ certbot_version }}"
|
||||
update: "{{ certbot_keep_updated }}"
|
||||
- include: include-vars.yml
|
||||
|
||||
- name: Ensure certbot-auto is executable.
|
||||
file:
|
||||
path: "{{ certbot_dir }}/certbot-auto"
|
||||
mode: 0755
|
||||
- include: install-with-package.yml
|
||||
when: not certbot_install_from_source
|
||||
|
||||
- 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 }}"
|
||||
- include: install-from-source.yml
|
||||
when: certbot_install_from_source
|
||||
|
||||
- include: renew-cron.yml
|
||||
when: certbot_auto_renew
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: Add cron job for certbot renewal (if configured).
|
||||
cron:
|
||||
name: Certbot automatic renewal.
|
||||
job: "{{ certbot_script }} renew --quiet --no-self-upgrade"
|
||||
minute: "{{ certbot_auto_renew_minute }}"
|
||||
hour: "{{ certbot_auto_renew_hour }}"
|
||||
user: "{{ certbot_auto_renew_user }}"
|
||||
@@ -0,0 +1,11 @@
|
||||
# Ansible Role tests
|
||||
|
||||
To run the test playbook(s) in this directory:
|
||||
|
||||
1. Install and start Docker.
|
||||
1. Download the test shim (see .travis.yml file for the URL) into `tests/test.sh`:
|
||||
- `wget -O tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/`
|
||||
1. Make the test shim executable: `chmod +x tests/test.sh`.
|
||||
1. Run (from the role root directory) `distro=[distro] playbook=[playbook] ./tests/test.sh`
|
||||
|
||||
If you don't want the container to be automatically deleted after the test playbook is run, add the following environment variables: `cleanup=false container_id=$(date +%s)`
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
- hosts: all
|
||||
|
||||
vars:
|
||||
certbot_install_from_source: yes
|
||||
|
||||
pre_tasks:
|
||||
- name: Update apt cache.
|
||||
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
|
||||
- role_under_test
|
||||
@@ -16,5 +16,4 @@
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
roles:
|
||||
- geerlingguy.git
|
||||
- role_under_test
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
certbot_package: letsencrypt
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
certbot_package: certbot
|
||||
Reference in New Issue
Block a user