summaryrefslogtreecommitdiffstats
path: root/roles/stream/tasks/main.yml
blob: eaf2fc8793f2d9bdd8be7c5e90dad2581cf48881 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
- name: Install at for scheduling commands
  become: true
  package:
    name: at
    state: present
- name: Install Icecast
  become: true
  package:
    name: icecast2
    state: present
- name: Install package for setting htpasswd
  package:
    name: python3-passlib
  when: protect_stream_with_password
- name: Create htpasswd entry
  htpasswd:
    create: yes
    name: "{{ emacsconf_backstage_user }}"
    password: "{{ emacsconf_backstage_password }}"
    path: /etc/nginx/{{ emacsconf_id }}-htpasswd
  when: protect_stream_with_password
- name: Set up config
  become: true
  template:
    src: icecast.xml
    dest: /etc/icecast2/icecast-{{ emacsconf_id }}.xml
- name: Create restream dir
  file:
    path: "{{ icecast_restream_dir }}"
    owner: "{{ icecast_user }}"
    state: directory
- name: Set up track-specific things
  include_tasks: track.yml
  loop: "{{ emacsconf_tracks }}"
- name: Set up init file
  become: true
  template:
    src: icecast-emacsconf.init.d
    dest: /etc/init.d/{{ emacsconf_id }}
    mode: 0755
- name: Set up nginx config
  tags: stream-nginx
  become: true
  template:
    src: emacsconf.nginx.conf
    dest: /etc/nginx/{{ emacsconf_id }}.nginx.conf
    mode: 0644
- name: Include emacsconf in nginx config
  become: true
  lineinfile:
    line: include /etc/nginx/{{ emacsconf_id }}.nginx.conf;
    regexp: '^\s*include /etc/nginx/{{ emacsconf_id }}.nginx.conf;'
    insertafter: '.*tls/live0.conf.*'
    backup: yes
    path: /etc/nginx/sites-available/live0.{{ emacsconf_id }}.org
- name: Reload nginx config
  service:
    name: nginx
    state: reloaded
- name: Enable icecast
  become: true
  service:
    name: emacsconf
    state: started
    enabled: yes
- name: Check if icecast is listening
  wait_for:
    port: "{{ icecast_port }}"
    delay: 5
    timeout: 20
    msg: "Timeout waiting for {{ icecast_port }} to respond"
  register: port_check
  ignore_errors: yes
- name: Try to restart icecast if not started
  service: name={{ emacsconf_id }} state=started enabled=yes
  when: port_check.failed == true
- name: Set up restream scripts
  tags: restream
  template:
    src: restream.sh
    dest: /usr/local/bin/restream-{{ item[1].name }}-{{ item[0].name }}
    owner: orga
    mode: 0755
  loop: "{{ restreaming_platforms | subelements('streams') | list }}"
  # no_log: True
- name: Set up restream scripts
  tags: restream
  template:
    src: screen-restream.sh
    dest: /usr/local/bin/screen-restream-{{ item[1].name }}-{{ item[0].name }}.sh
    owner: orga
    mode: 0755
  loop: "{{ restreaming_platforms | subelements('streams') | list }}"
  # no_log: True
- name: Copy fallback files
  copy:
    src: sorry.webm
    dest: /usr/share/icecast2/web/fallback.webm
    mode: 0644
    owner: "{{ icecast_user }}"
    group: "{{ icecast_group }}"
- name: Copy 480p fallback files
  copy:
    src: sorry-480p.webm
    dest: /usr/share/icecast2/web/480p-fallback.webm
    mode: 0644
    owner: "{{ icecast_user }}"
    group: "{{ icecast_group }}"
- name: Make a script to kick off all the fallbacks
  template:
    src: screen-fallbacks
    dest: /usr/local/bin/screen-fallbacks
    mode: 0755
    owner: "{{ icecast_user }}"
    group: "{{ icecast_group }}"