Add certbot role

This commit is contained in:
Ryan Cavicchioni 2019-11-24 18:50:05 -06:00
parent e3cdb84192
commit 932f04db5b
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
5 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,3 @@
---
certbot_package_name: certbot
certbot_package_state: present

View File

@ -0,0 +1,4 @@
---
- name: configure ppa
apt_repository:
repo: "ppa:certbot/certbot"

View File

@ -0,0 +1,9 @@
---
- name: "determine if certificate for {{ item.domains | join(', ') }}"
stat:
path: "/etc/letsencrypt/live/{{ item.domains | first }}/cert.pem"
register: st
- name: "request certificate for {{ item.domains | join(', ') }}"
command: "[[ ! -e certbot certonly --webroot -w {{ certbot_challenge_webroot_path }} --agree-tos --noninteractive --email {{ item.email }} -d {{ item.domains | join(',') }}"
when: not st.stat.exists

View File

@ -0,0 +1,41 @@
---
- name: gather os specific variables
include_vars: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
include_tasks: "{{ lookup('first_found', possible_files) }}"
vars:
possible_files:
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
- name: install certbot modules
package:
name: "{{ certbot_package_name }}"
state: "{{ certbot_package_state }}"
- name: configure challenge webroot
file:
path: "{{ certbot_challenge_webroot_path }}"
state: "directory"
owner: root
group: root
mode: 0755
- name: request certificates
include_tasks: "issue.yaml"
loop: "{{ certbot_certificates }}"

View File

@ -0,0 +1,2 @@
---
certbot_challenge_webroot_path: /var/www/.acme-challenge