2019-11-25 00:50:05 +00:00
|
|
|
---
|
|
|
|
- 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 }}"
|
2019-11-27 22:10:19 +00:00
|
|
|
|
|
|
|
- name: configure systemd timer
|
|
|
|
block:
|
|
|
|
- name: create systemd timer override directory
|
|
|
|
file:
|
|
|
|
path: "/etc/systemd/system/{{ certbot_timer_name }}.d"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0755
|
|
|
|
state: directory
|
|
|
|
|
|
|
|
- name: configure systemd timer options
|
|
|
|
template:
|
|
|
|
src: certbot.timer.j2
|
|
|
|
dest: "/etc/systemd/system/{{ certbot_timer_name }}.d/override.conf"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify: systemd daemon-reload
|
|
|
|
- name: enable the timer
|
|
|
|
systemd:
|
|
|
|
name: "{{ certbot_timer_name }}"
|
|
|
|
state: "{{ certbot_timer_state }}"
|
|
|
|
enabled: "{{ certbot_timer_enabled }}"
|
|
|
|
when: ansible_service_mgr == "systemd"
|
|
|
|
|
|
|
|
- name: configure cron job
|
|
|
|
block:
|
|
|
|
- name: configure env
|
|
|
|
cron:
|
|
|
|
name: "{{ item.key | upper }}"
|
|
|
|
env: yes
|
|
|
|
job: "{{ item.value }}"
|
|
|
|
user: "{{ certbot_cron_user }}"
|
|
|
|
cron_file: "{{ certbot_cron_file_path }}"
|
2019-11-27 22:43:04 +00:00
|
|
|
state: "{{ certbot_cron_state }}"
|
2019-11-27 22:10:19 +00:00
|
|
|
loop: "{{ certbot_cron_env | dict2items }}"
|
|
|
|
- name: create job
|
|
|
|
cron:
|
|
|
|
name: certbot
|
|
|
|
user: "{{ certbot_cron_user }}"
|
|
|
|
hour: "{{ certbot_cron_hour }}"
|
|
|
|
minute: "{{ certbot_cron_minute }}"
|
|
|
|
cron_file: "{{ certbot_cron_file_path }}"
|
|
|
|
job: "{{ certbot_cron_command }}"
|
2019-11-27 22:43:04 +00:00
|
|
|
state: "{{ certbot_cron_state }}"
|