handle default and per vhost ports

This commit is contained in:
Antonio J. Delgado 2023-09-24 10:12:28 +03:00
parent 1d15dab732
commit 0fb2850687
3 changed files with 24 additions and 5 deletions

View file

@ -1,14 +1,30 @@
--- ---
- name: Allow HTTP traffic - name: Allow default HTTP traffic
ufw: ufw:
rule: allow rule: allow
port: "{{ web_port }}" port: "{{ web_port }}"
- name: Allow HTTPS traffic - name: Allow HTTP traffic for vhosts
ufw:
rule: allow
port: "{{ item.web_port }}"
loop: "{{ vhosts }}"
- name: Allow HTTPS default traffic
ufw: ufw:
rule: allow rule: allow
port: "{{ ssl_port | default(443) }}" port: "{{ ssl_port | default(443) }}"
when: ssl when:
- ssl
- name: Allow HTTPS traffic for vhosts
ufw:
rule: allow
port: "{{ item.ssl_port | default(443) }}"
loop: "{{ vhosts }}"
when:
- ssl
- item.ssl
- name: Ensure MPM Worker module is disabled - name: Ensure MPM Worker module is disabled
shell: a2dismod mpm_worker shell: a2dismod mpm_worker

View file

@ -12,5 +12,5 @@
creates: "/etc/letsencrypt/archive/{{ item.vhostname }}" creates: "/etc/letsencrypt/archive/{{ item.vhostname }}"
when: when:
- "'ssl' in item" - "'ssl' in item"
- item['ssl'] - item.ssl
loop: "{{ vhosts }}" loop: "{{ vhosts }}"

View file

@ -10,7 +10,9 @@
path: "/etc/letsencrypt/archive/{{ item.vhostname }}" path: "/etc/letsencrypt/archive/{{ item.vhostname }}"
register: certificate_folder register: certificate_folder
loop: "{{ vhosts }}" loop: "{{ vhosts }}"
when: ssl when:
ssl
item.ssl
- name: Initialize need_certificate - name: Initialize need_certificate
set_fact: set_fact:
@ -23,6 +25,7 @@
when: when:
- not item.stat.exists - not item.stat.exists
- ssl - ssl
- item.ssl
loop: "{{ certificate_folder.results }}" loop: "{{ certificate_folder.results }}"
- name: Ensure certificate is created if needed - name: Ensure certificate is created if needed