add coturn service

This commit is contained in:
2023-10-31 02:11:43 +01:00
parent 105ee89080
commit 7910336c5d
9 changed files with 265 additions and 2 deletions

View File

@@ -0,0 +1,4 @@
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew --no-random-sleep-on-renew; setfacl -R -m u:turnserver:rx /etc/letsencrypt/; systemctl restart coturn;

View File

@@ -0,0 +1,17 @@
tls-listening-port=__PORT__
listening-ip=__IP_CONTAINER__
relay-ip=__IP_CONTAINER__
external-ip=__IP_EXT__
server-name=__HOSTNAME__
lt-cred-mech
realm=__HOSTNAME__
#use-auth-secret
#static-auth-secret=""
cert=__SSL_CRT__
pkey=__SSL_KEY__
no-stdout-log
cipher-list="EECDH+AESGCM:EDH+AESGCM"
ec-curve-name=secp384r1
dh2066
no-tlsv1
no-tlsv1_1

107
roles/coturn/tasks/main.yml Normal file
View File

@@ -0,0 +1,107 @@
- name: Install CoTurn
apt:
name:
- coturn
- acl
state: present
- name: Allow Turnserver connexions
ufw:
rule: allow
port: "{{ turnserver_port }}"
proto: any
- name: Copy Configuration file for coturn
ansible.builtin.copy:
src: turnserver.conf
dest: /etc/turnserver.conf
owner: root
group: root
mode: '0644'
- name: Add port to listen on turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__PORT__'
replace: '{{ turnserver_port }}'
- name: Add hostname on turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__HOSTNAME__'
replace: '{{ domain }}'
- name: Add IP to listen on turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__IP_CONTAINER__'
replace: '{{ ip_listen }}'
- name: Add IP public on turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__IP_EXT__'
replace: '{{ ip_public }}'
- name: Add port to listen on turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__PASSPHRASE__'
replace: '{{ passphrase }}'
- name: Add SSL keys to turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__SSL_CRT__'
replace: '/etc/ssl/{{ domain}}.crt'
when: installCertbot == False
- name: Add SSL keys to turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__SSL_KEY__'
replace: '/etc/ssl/{{ domain}}.key'
when: installCertbot == False
- name: permission to ssl cert
shell: |
setfacl -R -m u:turnserver:rx /etc/ssl/"{{ domain }}".key
setfacl -R -m u:turnserver:rx /etc/ssl/"{{ domain }}".crt
when: installCertbot == False
- name: Add SSL keys to turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__SSL_CRT__'
replace: '/etc/letsencrypt/live/{{ domain }}/fullchain.pem'
when: installCertbot == True
- name: Add SSL keys to turnserver.conf
ansible.builtin.replace:
path: /etc/turnserver.conf
regexp: '__SSL_KEY__'
replace: '/etc/letsencrypt/live/{{ domain }}/privkey.pem'
when: installCertbot == True
- name: Set permission letsencrypt SSL keys
shell: setfacl -R -m u:turnserver:rx /etc/letsencrypt/
when: installCertbot == True
- name: Start coturn service
shell: "systemctl start coturn"
- name: Enable systemd service
shell: "systemctl enable coturn"
- name: Copy Configuration file for coturn
ansible.builtin.copy:
src: certbot-cron
dest: /etc/cron.d/certbot
owner: root
group: root
mode: '0644'
when: installCertbot == True