2018-06-22 21:18:48 +02:00
|
|
|
---
|
2020-04-20 23:21:54 +02:00
|
|
|
- name: Create certbot user '{{ certbot_user }}'
|
|
|
|
user:
|
|
|
|
name: "{{ certbot_user }}"
|
2019-09-18 16:37:54 +02:00
|
|
|
become: True
|
|
|
|
become_user: root
|
2020-04-20 23:21:54 +02:00
|
|
|
when: not certbot_user == 'root'
|
2018-06-22 21:18:48 +02:00
|
|
|
|
2019-09-18 16:37:54 +02:00
|
|
|
- block:
|
2020-05-10 17:05:23 +02:00
|
|
|
- name: Install dependencies
|
|
|
|
pip:
|
|
|
|
name: "{{ item }}"
|
2020-05-22 22:26:37 +02:00
|
|
|
extra_args: --user
|
2020-05-22 23:00:28 +02:00
|
|
|
state: present
|
2020-05-10 17:05:23 +02:00
|
|
|
loop: "{{ certbot_packages_extra }}"
|
|
|
|
|
2020-04-20 23:25:13 +02:00
|
|
|
- name: Install certbot with pip
|
|
|
|
pip:
|
|
|
|
name: "{{ item }}"
|
|
|
|
extra_args: --user
|
2020-04-21 00:33:37 +02:00
|
|
|
state: present
|
2020-05-10 17:05:23 +02:00
|
|
|
loop: "{{ __certbot_packages }}"
|
2020-04-20 23:21:54 +02:00
|
|
|
|
2018-06-22 21:18:48 +02:00
|
|
|
- name: Create certbot environment
|
2018-06-22 21:39:52 +02:00
|
|
|
file:
|
|
|
|
path: "{{ item.name }}"
|
2018-06-22 21:18:48 +02:00
|
|
|
state: directory
|
2018-06-22 21:39:52 +02:00
|
|
|
mode: "{{ item.mode }}"
|
2020-04-19 23:37:59 +02:00
|
|
|
loop: "{{ __certbot_environment }}"
|
2018-06-22 21:45:25 +02:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
2018-06-22 21:18:48 +02:00
|
|
|
|
|
|
|
- name: Deploy config file
|
|
|
|
template:
|
2018-06-22 21:59:02 +02:00
|
|
|
src: config/cli.ini.j2
|
2018-06-22 22:50:24 +02:00
|
|
|
dest: "{{ certbot_config_dir }}/cli.ini"
|
2018-06-22 23:16:49 +02:00
|
|
|
|
2020-04-19 23:27:41 +02:00
|
|
|
- name: Deploy credentials file
|
|
|
|
template:
|
|
|
|
src: config/credentials.ini.j2
|
|
|
|
dest: "{{ certbot_config_dir }}/credentials.ini"
|
2020-04-21 00:25:08 +02:00
|
|
|
mode: 0600
|
2020-04-20 23:39:41 +02:00
|
|
|
when: certbot_credentials | default([]) | length > 0
|
2020-04-19 23:27:41 +02:00
|
|
|
|
2018-06-22 23:16:49 +02:00
|
|
|
- name: Schedule certbot run
|
|
|
|
cron:
|
2020-05-22 22:21:55 +02:00
|
|
|
name: "Certbot automatic renewal: {{ item.name }}"
|
2020-04-19 23:27:41 +02:00
|
|
|
minute: "{{ certbot_cron_minute }}"
|
|
|
|
hour: "{{ certbot_cron_hour }}"
|
|
|
|
user: "{{ certbot_cron_user | default(certbot_user) }}"
|
2018-06-26 21:09:16 +02:00
|
|
|
job: >
|
2020-04-21 00:10:25 +02:00
|
|
|
{{ certbot_bin | default(__certbot_bin) }}
|
2018-06-23 18:37:26 +02:00
|
|
|
--config-dir {{ certbot_config_dir }}
|
|
|
|
--work-dir {{ certbot_work_dir }}
|
|
|
|
--logs-dir {{ certbot_log_dir }}
|
2018-06-26 21:11:52 +02:00
|
|
|
{{ certbot_command_arguments | join(' ') }}
|
2020-05-22 22:21:55 +02:00
|
|
|
-n -d {{ item.domains | join(',') }}
|
2020-04-19 23:27:41 +02:00
|
|
|
cron_file: "{{ certbot_cron_file | default(omit) }}"
|
2020-05-22 22:21:55 +02:00
|
|
|
loop: "{{ certbot_domain_groups }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ item.name }}"
|
2020-04-20 22:47:48 +02:00
|
|
|
when: certbot_cron_enabled
|
2018-06-22 21:18:48 +02:00
|
|
|
become: True
|
|
|
|
become_user: "{{ certbot_user }}"
|