To allow for other domains
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2848|23|2825|3|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/jitsimeet/21//ansiblelint">Evolix » ansible-roles » jitsimeet #21</a>
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
Mathieu Gauthier-Pilote 2024-01-10 13:22:34 -05:00
parent 720453e4e0
commit 2a8d989b86
2 changed files with 77 additions and 0 deletions

View file

@ -201,3 +201,9 @@
- name: Generate certificate for coturn with certbot
shell: certbot certonly --webroot --webroot-path /var/lib/letsencrypt --non-interactive --deploy-hook /etc/letsencrypt/renewal-hooks/deploy/coturn-certbot-deploy.sh --agree-tos --email {{ certbot_admin_email }} -d {{ turn_domains |first }}
when: ssl_coturn.stat.exists != true
- name: Setup other domains if any
include_tasks: other_domains.yml
loop: "{{ domains[1:] }}"
loop_control:
loop_var: domain

View file

@ -0,0 +1,71 @@
---
# tasks file for other domains if any
- name: Template config files
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
loop:
- { src: 'meet/config.js.j2', dest: "/etc/jitsi/meet/{{ domain }}-config.js", owner: "root", group: "root", mode: "0644" }
- name: Check if SSL certificate is present and register result
stat:
path: "/etc/letsencrypt/live/{{ domain }}/fullchain.pem"
register: ssl
- name: Generate certificate only if required (first time)
block:
- name: Template vhost without SSL for successfull LE challengce
template:
src: "nginx/vhost.conf.j2"
dest: "/etc/nginx/sites-available/{{ domain }}.conf"
- name: Enable temporary nginx vhost
file:
src: "/etc/nginx/sites-available/{{ domain }}.conf"
dest: "/etc/nginx/sites-enabled/{{ domain }}.conf"
state: link
- name: Reload nginx conf
service:
name: nginx
state: reloaded
- name: Make sure /var/lib/letsencrypt exists and has correct permissions
file:
path: /var/lib/letsencrypt
state: directory
mode: '0755'
- name: Generate certificate with certbot
shell: certbot certonly --webroot --webroot-path /var/lib/letsencrypt --non-interactive --agree-tos --email {{ certbot_admin_email }} -d {{ domain }}
when: ssl.stat.exists != true
- name: (Re)check if SSL certificate is present and register result
stat:
path: "/etc/letsencrypt/live/{{ domain |first }}/fullchain.pem"
register: ssl
- name: (Re)template conf file for nginx vhost with SSL
template:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
loop:
- { src: 'nginx/vhost.conf.j2', dest: "/etc/nginx/sites-available/{{ domain }}.conf" }
- { src: 'nginx/multiplex.conf.j2', dest: '/etc/nginx/modules-available/multiplex.conf' }
- name: Enable multiplex module conf
file:
src: '/etc/nginx/modules-available/multiplex.conf'
dest: '/etc/nginx/modules-enabled/multiplex.conf'
state: link
- name: Enable nginx vhost
file:
src: "/etc/nginx/sites-available/{{ domain }}.conf"
dest: "/etc/nginx/sites-enabled/{{ domain }}.conf"
state: link
- name: Reload nginx conf
service:
name: nginx
state: reloaded