xoxys.certbot/tasks/install.yml

68 lines
1.9 KiB
YAML
Raw Normal View History

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