Merge 5f54b5d397863c41ea4c329988fb317ac830f95b into 3dedd45961a41ae7d01bdc408158daeabf7acaa7

This commit is contained in:
Peter Janes 2017-03-18 11:37:20 +00:00 committed by GitHub
commit 64f7eb8099
7 changed files with 55 additions and 31 deletions

View File

@ -2,30 +2,31 @@
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-certbot.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-certbot) [![Build Status](https://travis-ci.org/geerlingguy/ansible-role-certbot.svg?branch=master)](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 ## Requirements
Certbot requires Git to be installed. You can install Git using the `geerlingguy.git` role. Certbot requires Git to be installed if one wants to install Certbot from Git repository instead of package management. You can install Git using the `geerlingguy.git` role.
## Role Variables ## Role Variables
certbot_from_git: no
certbot_repo: https://github.com/certbot/certbot.git certbot_repo: https://github.com/certbot/certbot.git
certbot_version: master certbot_version: master
certbot_keep_updated: yes 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 Git repository options. This role clones the agent from the configured repo, then makes the `certbot-auto` script executable if `certbot_from_git` is `yes`. Otherwise it will be installed from distribution's package management.
certbot_dir: /opt/certbot certbot_dir: /opt/certbot
The directory inside which Certbot will be cloned. The directory inside which Certbot will be cloned when using Git.
certbot_auto_renew: true certbot_auto_renew: true
certbot_auto_renew_user: "{{ ansible_user }}" certbot_auto_renew_user: "{{ ansible_user }}"
certbot_auto_renew_hour: 3 certbot_auto_renew_hour: 3
certbot_auto_renew_minute: 30 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.
## Dependencies ## Dependencies
@ -34,20 +35,20 @@ None.
## Example Playbook ## Example Playbook
- hosts: servers - hosts: servers
vars: vars:
certbot_auto_renew_user: your_username_here certbot_auto_renew_user: your_username_here
certbot_auto_renew_minute: 20 certbot_auto_renew_minute: 20
certbot_auto_renew_hour: 5 certbot_auto_renew_hour: 5
roles: roles:
- geerlingguy.certbot - 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!). # Automatically add certs for all Apache virtualhosts (use with caution!).
/opt/certbot/certbot-auto --apache /opt/certbot/certbot-auto --apache
# Generate certs, but don't modify Apache configuration (safer). # Generate certs, but don't modify Apache configuration (safer).
/opt/certbot/certbot-auto --apache certonly /opt/certbot/certbot-auto --apache certonly

View File

@ -1,10 +1,11 @@
--- ---
# Where to get Certbot. # Where to get Certbot.
certbot_from_git: no
certbot_repo: https://github.com/certbot/certbot.git certbot_repo: https://github.com/certbot/certbot.git
certbot_version: master certbot_version: master
certbot_keep_updated: yes certbot_keep_updated: yes
# Where to put Certbot. # Where to put Certbot when cloning from Git.
certbot_dir: /opt/certbot certbot_dir: /opt/certbot
# How to keep Certbot certs up to date. # How to keep Certbot certs up to date.

View File

@ -3,7 +3,7 @@ dependencies: []
galaxy_info: galaxy_info:
author: geerlingguy 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" company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)" license: "license (BSD, MIT)"
min_ansible_version: 1.8 min_ansible_version: 1.8
@ -12,12 +12,15 @@ galaxy_info:
versions: versions:
- 6 - 6
- 7 - 7
- name: Fedora
versions:
- all
- name: Ubuntu - name: Ubuntu
versions: versions:
- all - all
- name: Debian - name: Debian
versions: versions:
- all - all
galaxy_tags: galaxy_tags:
- networking - networking
- system - system

View File

@ -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

View File

@ -0,0 +1,7 @@
---
- name: Install Certbot
package: name=certbot state=present
- name: Set Certbot script variable
set_fact:
certbot_script: certbot

View File

@ -1,22 +1,9 @@
--- ---
- name: Clone Certbot into configured directory. - include: install-from-package.yml
git: when: not certbot_from_git and (ansible_distribution == 'Fedora' or ansible_distribution == 'RedHat')
repo: "{{ certbot_repo }}"
dest: "{{ certbot_dir }}"
version: "{{ certbot_version }}"
update: "{{ certbot_keep_updated }}"
force: yes
- name: Ensure certbot-auto is executable. - include: install-from-git.yml
file: when: certbot_from_git or (ansible_distribution != 'Fedora' and ansible_distribution != 'RedHat')
path: "{{ certbot_dir }}/certbot-auto"
mode: 0755
- name: Add cron job for 'certbot-auto renew' (if configured). - include: renew-cron.yml
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 when: certbot_auto_renew

8
tasks/renew-cron.yml Normal file
View File

@ -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 }}"