xoxys.certbot/tasks/install.yml

104 lines
3.0 KiB
YAML
Raw Normal View History

---
- name: Create certbot user '{{ certbot_user }}'
user:
name: "{{ certbot_user }}"
2019-09-18 16:37:54 +02:00
become: True
become_user: root
when: not certbot_user == 'root'
2019-09-18 16:37:54 +02:00
- block:
2021-04-17 12:20:07 +02:00
- name: Upgrade python dependencies
pip:
name: "{{ item }}"
virtualenv: "{{ certbot_virtualenv }}"
virtualenv_command: "{{ certbot_virtualenv_command }} -m venv"
2021-04-17 12:20:07 +02:00
extra_args: --upgrade
loop:
- pip
- setuptools
2020-05-10 17:05:23 +02:00
- name: Install dependencies
pip:
name: "{{ item }}"
virtualenv: "{{ certbot_virtualenv }}"
virtualenv_command: "{{ certbot_virtualenv_command }} -m venv"
2021-04-17 12:20:07 +02:00
environment:
TMPDIR: /opt/python3/tmp
2020-05-10 17:05:23 +02:00
loop: "{{ certbot_packages_extra }}"
2021-04-17 12:20:07 +02:00
- name: Install certbot
2020-04-20 23:25:13 +02:00
pip:
name: "{{ item }}"
virtualenv: "{{ certbot_virtualenv }}"
virtualenv_command: "{{ certbot_virtualenv_command }} -m venv"
2020-05-10 17:05:23 +02:00
loop: "{{ __certbot_packages }}"
2021-04-17 12:20:07 +02:00
- name: Adjust file permissions
file:
name: "{{ certbot_virtualenv }}"
2021-04-17 12:20:07 +02:00
recurse: True
mode: u+rwX,go+rX,go-w
state: directory
- name: Make certbot binaries executable
file:
name: "{{ certbot_virtualenv }}/bin/{{ item }}"
2021-04-17 12:20:07 +02:00
mode: 0755
loop: "{{ __certbot_binaries }}"
- name: Deploy certbot bin wrappers
template:
src: usr/local/bin/certbot-wrapper.j2
dest: "/usr/local/bin/{{ item }}"
owner: root
group: root
mode: 0755
loop: "{{ __certbot_binaries }}"
become: True
become_user: root
- block:
- name: Create certbot environment
2018-06-22 21:39:52 +02:00
file:
path: "{{ item.name }}"
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 }}"
- 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"
2021-02-06 15:15:59 +01:00
mode: 0640
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 }}
2021-06-04 08:45:03 +02:00
--max-log-backups {{ certbot_max_log_backups }}
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
become: True
become_user: "{{ certbot_user }}"