2022-03-12 19:42:26 +01:00
|
|
|
---
|
|
|
|
- name: Install certbot
|
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
ansible.builtin.apt:
|
2022-03-12 19:42:26 +01:00
|
|
|
name: certbot
|
|
|
|
state: present
|
2022-06-25 14:48:38 +02:00
|
|
|
update_cache: true
|
2022-03-13 10:05:11 +01:00
|
|
|
|
2023-01-19 16:14:31 +01:00
|
|
|
- name: Create acme directories
|
2022-03-13 10:05:11 +01:00
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
ansible.builtin.file:
|
2023-01-19 16:14:31 +01:00
|
|
|
path: "{{ item }}"
|
2022-03-13 10:05:11 +01:00
|
|
|
state: directory
|
2022-03-13 11:30:35 +01:00
|
|
|
mode: 0755
|
2023-01-19 16:14:31 +01:00
|
|
|
with_items:
|
|
|
|
- /var/www/acme
|
|
|
|
- /var/www/acme/.well-known
|
|
|
|
- /var/www/acme/.well-known/acme-challenge
|
2022-03-13 11:30:35 +01:00
|
|
|
|
2022-03-15 15:31:12 +01:00
|
|
|
- name: Enable modules
|
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
community.general.apache2_module:
|
2022-03-15 15:31:12 +01:00
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items:
|
|
|
|
- rewrite
|
|
|
|
- ssl
|
|
|
|
notify: Reload apache2 service
|
|
|
|
|
2022-03-15 15:53:54 +01:00
|
|
|
- name: Copy apache confs
|
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
ansible.builtin.copy:
|
|
|
|
src: "{{ item.src }}"
|
|
|
|
dest: "{{ item.dest }}"
|
|
|
|
mode: 0644
|
2022-03-15 15:53:54 +01:00
|
|
|
with_items:
|
2022-06-25 14:48:38 +02:00
|
|
|
- {src: 'acme.conf', dest: '/etc/apache2/conf-available/acme.conf'}
|
|
|
|
- {src: 'ssl-options.conf', dest: '/etc/apache2/conf-available/ssl-options.conf'}
|
2022-03-15 15:53:54 +01:00
|
|
|
|
|
|
|
- name: Enable apache confs
|
2022-03-13 11:30:35 +01:00
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
ansible.builtin.command: a2enconf {{ item }}
|
2022-03-15 15:53:54 +01:00
|
|
|
with_items:
|
|
|
|
- acme
|
|
|
|
- ssl-options
|
2022-03-13 11:30:35 +01:00
|
|
|
register: result
|
|
|
|
changed_when: "'already enabled' not in result.stdout"
|
|
|
|
notify: Reload apache2 service
|
2022-03-13 11:46:24 +01:00
|
|
|
|
|
|
|
- name: Allow certbot renewal
|
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
ansible.builtin.copy:
|
2022-03-13 11:46:24 +01:00
|
|
|
src: http-certbot.conf
|
|
|
|
dest: /etc/nftables/input.d/http-certbot.conf
|
2022-06-25 14:48:38 +02:00
|
|
|
mode: 0640
|
2022-03-13 11:46:24 +01:00
|
|
|
notify: Reload nftables service
|
2022-03-15 15:53:54 +01:00
|
|
|
|
|
|
|
- name: Allow incoming HTTPS
|
|
|
|
become: true
|
2022-12-16 20:12:49 +01:00
|
|
|
ansible.builtin.copy:
|
2022-03-15 15:53:54 +01:00
|
|
|
src: https.conf
|
|
|
|
dest: /etc/nftables/input.d/https.conf
|
2022-06-25 14:48:38 +02:00
|
|
|
mode: 0640
|
2022-03-15 15:53:54 +01:00
|
|
|
notify: Reload nftables service
|