diff options
Diffstat (limited to 'roles/streaming')
-rw-r--r-- | roles/streaming/icecast/defaults/main.yml | 24 | ||||
-rw-r--r-- | roles/streaming/icecast/tasks/main.yml | 40 | ||||
-rw-r--r-- | roles/streaming/icecast/templates/icecast.xml.j2 | 71 | ||||
-rw-r--r-- | roles/streaming/icecast/templates/pod-spec.yml.j2 | 31 |
4 files changed, 166 insertions, 0 deletions
diff --git a/roles/streaming/icecast/defaults/main.yml b/roles/streaming/icecast/defaults/main.yml new file mode 100644 index 00000000..673284fd --- /dev/null +++ b/roles/streaming/icecast/defaults/main.yml @@ -0,0 +1,24 @@ +--- +icecast_base_path: /srv/icecast + +# icecast_instances: +# example: +# image_version: 2021-04-23.1 +# port: 8080 + +# source_password: quite-secret +# relay_password: quite-secret +# admin: +# username: admin +# password: very-secret + +# ## optional +# hostname: stream.example.com +# location: Graz/Austria +# contact: icecast@example.com + +# mountpoints: +# '/test.mp3': +# username: ## optional +# password: secret +# max_listeners: ## optional diff --git a/roles/streaming/icecast/tasks/main.yml b/roles/streaming/icecast/tasks/main.yml new file mode 100644 index 00000000..cbd9f909 --- /dev/null +++ b/roles/streaming/icecast/tasks/main.yml @@ -0,0 +1,40 @@ +--- +- name: create icecast instance directory + loop: "{{ icecast_instances | list }}" + file: + path: "{{ icecast_base_path }}/{{ item }}" + state: directory + +- name: create icecast log directory + loop: "{{ icecast_instances | list }}" + file: + dest: "{{ icecast_base_path }}/{{ item }}/logs" + state: directory + owner: app + group: app + +- name: generate icecast config + loop: "{{ icecast_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + template: + src: icecast.xml.j2 + dest: "{{ icecast_base_path }}/{{ item.key }}/icecast.xml" + owner: root + group: app + mode: 0640 + +- name: install pod manifest + loop: "{{ icecast_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + vars: + kubernetes_standalone_pod: + name: "icecast-{{ item.key }}" + spec: "{{ lookup('template', 'pod-spec.yml.j2') }}" + config_hash_items: + - path: "{{ icecast_base_path }}/{{ item.key }}/icecast.xml" + properties: + - checksum + include_role: + name: kubernetes/standalone/pod diff --git a/roles/streaming/icecast/templates/icecast.xml.j2 b/roles/streaming/icecast/templates/icecast.xml.j2 new file mode 100644 index 00000000..3bf0044a --- /dev/null +++ b/roles/streaming/icecast/templates/icecast.xml.j2 @@ -0,0 +1,71 @@ +<icecast> +<!-- ***** global ***** --> + <listen-socket> + <port>8080</port> + </listen-socket> + + <limits> + <threadpool>5</threadpool> + <queue-size>524288</queue-size> + <client-timeout>30</client-timeout> + <header-timeout>15</header-timeout> + <source-timeout>10</source-timeout> + <burst-on-connect>1</burst-on-connect> + <burst-size>32768</burst-size> + </limits> + + <authentication> + <source-password>{{ item.value.source_password }}</source-password> + <relay-password>{{ item.value.relay_password }}</relay-password> + <admin-user>{{ item.value.admin.username }}</admin-user> + <admin-password>{{ item.value.admin.password }}</admin-password> + </authentication> + +{% if 'hostname' in item.value %} + <hostname>{{ item.value.hostname }}</hostname> +{% endif %} +{% if 'location' in item.value %} + <location>{{ item.value.location }}</location> +{% endif %} +{% if 'contact' in item.value %} + <admin>{{ item.value.contact }}</admin> +{% endif %} + + +<!-- ***** mountpoints ***** --> +{% for mountpoint, config in item.value.mountpoints.items() %} + <mount> + <mount-name>{{ mountpoint }}</mount-name> +{% if 'username' in config %} + <username>{{ config.username }}</username> +{% endif %} + <password>{{ config.password }}</password> +{% if 'max_listeners' in config %} + <max-listeners>{{ config.max_listeners }}</max-listeners> +{% endif %} + </mount> + +{% endfor %} + +<!-- ***** aux ***** --> + <fileserve>1</fileserve> + <paths> + <basedir>/usr/share/icecast2</basedir> + <logdir>/srv/logs</logdir> + <webroot>/usr/share/icecast2/web</webroot> + <adminroot>/usr/share/icecast2/admin</adminroot> + <alias source="/" dest="/status.xsl"/> + </paths> + + <logging> + <errorlog>-</errorlog> + <accesslog>access.log</accesslog> + <loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error --> + <logsize>100000</logsize> <!-- Max size of a logfile --> + </logging> + + <security> + <chroot>0</chroot> + </security> +<!-- ***** end ***** --> +</icecast> diff --git a/roles/streaming/icecast/templates/pod-spec.yml.j2 b/roles/streaming/icecast/templates/pod-spec.yml.j2 new file mode 100644 index 00000000..5dc0b086 --- /dev/null +++ b/roles/streaming/icecast/templates/pod-spec.yml.j2 @@ -0,0 +1,31 @@ +securityContext: + allowPrivilegeEscalation: false + runAsUser: 990 + runAsGroup: 990 +containers: +- name: icecast + image: registry.gitlab.com/spreadspace/docker/icecast:{{ item.value.image_version }} + imagePullPolicy: Always + resources: + limits: + memory: "512Mi" + args: + - icecast2 + - -c + - /srv/icecast.xml + volumeMounts: + - name: home + mountPath: /srv/icecast.xml + subPath: icecast.xml + readOnly: true + - name: home + mountPath: /srv/logs + subPath: logs + ports: + - containerPort: 8080 + hostPort: {{ item.value.port }} + +volumes: +- name: home + hostPath: + path: "{{ icecast_base_path }}/{{ item.key }}" |