: add ampache
Some checks failed
ansible-lint / lint-everything (push) Failing after 1m51s

This commit is contained in:
VC
2025-09-08 20:30:30 +02:00
parent d779eb6ed7
commit 63b2dd952a
8 changed files with 1672 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
---
php_modules: ['opcache', 'mysql', 'mbstring', 'gd', 'intl', 'xml', 'curl']
web_hostname:
- host: amp.mateu.be
type: ampache
@@ -10,3 +12,37 @@ mariadb_root_pass: !vault |
62313461306232383261323363656636623961373462316236396161376466386237376434663165
3739333432313636390a343366626138663361653936306134323539393034316332666431633739
38633832326663623061396131316636336233373939393061363565653233636164
ampache_maria_user: "adm_ampache"
ampache_maria_database: "libertus_ampache"
ampache_maria_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
34313061393731613038613462303864626137623631313965356638316465643035373964373765
6633666431663139653832323836306162636465626335610a386535653238333836666162303637
33616535383332626461643634343065653432613063346263363366363733363165343230663436
3231333639313666350a373561613938326631336430346135323438626265666639333234396161
63316432353261653163336638613538383537656635636463393665336332653231
ampache_secret_key: !vault |
$ANSIBLE_VAULT;1.1;AES256
37353866623062613737313866323261363334633965313064366366333839653862376538363463
3330386361393362306437663163326330373635313063650a633866633032343162393231326266
63393565306465386361373236363135376666323663393966653564393066653039336137663265
6634356164636436610a626362646239343432663037623934393030356131663434303763663337
37323230613639376363346230346261323962616633636632623139656435363838
ampache_musicbrainz_username: !vault |
$ANSIBLE_VAULT;1.1;AES256
39363439306662643164353238343131303764316238663366633737626338306431666133363161
3632346334666466663935323638393065383030353338620a646265326135663266643235376235
36343831376137323661363535366535376430616230316562323131326634633636393432326462
3738303732366366620a633464616266666330386563393133613063333863663037373861366336
65623863393766376365643537636361636332373535393633636465616566366432333636643363
6236653638303435303134626630383634343132336463313565
ampache_musicbrainz_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
37363533353764366533343334383663356431646530633034333036306630376136346238653937
6165353865386239386433323263343636356635646134640a363734336266663833636431353634
61306165376364393563306666306630623538316632633666653732363830626662333336653135
6634656263326230360a323932396639666464353463333063613732363334333763613832366139
33633432346164373164613832326264646463336134336436623765313535376662303063306164
3164363264383832363135646331656537663262323463396137

View File

@@ -36,3 +36,10 @@
roles:
- role: wordpress
tags: [never, wordpress]
- name: Install libertus webapplications
hosts: web4
diff: true
roles:
- role: ampache
tags: [never, ampache]

View File

@@ -0,0 +1,42 @@
---
## Remove the previous app & install the new version
- name: Remove Ampache previous version
ansible.builtin.file:
state: absent
dest: "{{ ampache_app_home }}"
- name: Create app home
ansible.builtin.file:
state: directory
dest: "{{ ampache_app_home }}"
owner: root
group: www-data
mode: "0o750"
- name: Install ampache application
ansible.builtin.unarchive:
remote_src: true
src: "{{ ampache_url }}"
dest: "{{ ampache_app_home }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
# exclude: "{{ firefly3_userdata_app_dirs | map('regex_replace', '^', './') }}"
- name: Put config file
ansible.builtin.template:
src: "ampache.cfg.php.j2"
dest: "{{ ampache_app_home }}/config/ampache.cfg.php"
owner: root
group: www-data
mode: "0o640"
## Ensure the data dirs exists, populate them if not
- name: Create data home
ansible.builtin.file:
state: directory
path: "{{ ampache_data_home }}"
owner: www-data
group: www-data
mode: "0o750"

View File

@@ -0,0 +1,20 @@
---
- name: Create ampache db
community.mysql.mysql_db:
login_unix_socket: "/var/run/mysqld/mysqld.sock"
login_user: root
login_password: "{{ mariadb_root_pass }}"
name: "{{ ampache_maria_database }}"
state: present
encoding: utf8mb4
collation: utf8mb4_general_ci
- name: Create ampache db read/write user
community.mysql.mysql_user:
login_unix_socket: "/var/run/mysqld/mysqld.sock"
login_user: root
login_password: "{{ mariadb_root_pass }}"
name: "{{ ampache_maria_user }}"
password: "{{ ampache_maria_password }}"
priv: "{{ ampache_maria_database }}.*:ALL"

View File

@@ -0,0 +1,10 @@
---
- name: Init db
ansible.builtin.include_tasks: db.yml
- name: Install ampache
ansible.builtin.include_tasks: ampache.yml
#- name: Install firefly3 cron
# ansible.builtin.include_tasks: cron.yml

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
---
ampache_version: "7.7.2"
ampache_url: "https://github.com/ampache/ampache/releases/download/{{ ampache_version }}/ampache-{{ ampache_version }}_all_php{{ php_version }}.zip"
ampache_access_url: "{{ web_hostname | selectattr('type', 'defined') | selectattr('type', '==', 'ampache') | map(attribute='host') | first }}"
# Access path
ampache_app_home: "/var/www/{{ ampache_access_url }}"
ampache_data_home: "/srv/www-data/{{ ampache_access_url }}"

View File

@@ -0,0 +1,82 @@
server {
{% include './templates/header.conf.j2' %}
root /var/www/amp.mateu.be/public/;
index index.php;
# Somebody said this helps, in my setup it doesn't prevent temporary saving in files
proxy_max_temp_file_size 0;
# Rewrite rule for Subsonic backend
if ( !-d $request_filename ) {
rewrite ^/rest/(.*).view$ /rest/index.php?action=$1 last;
rewrite ^/rest/fake/(.+)$ /play/$1 last;
}
# Rewrite rule for Channels
if (!-d $request_filename){
rewrite ^/channel/([0-9]+)/(.*)$ /channel/index.php?channel=$1&target=$2 last;
}
# Beautiful URL Rewriting
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&name=$5 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&name=$6 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&player=$6&name=$7 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&bitrate=$6&player=$7&name=$8 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/transcode_to/(w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&transcode_to=$6&bitrate=$7&player=$8&name=$9 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/noscrobble/([0-1])/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&name=$7 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/noscrobble/([0-1])/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&player=$7&name=$8 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/noscrobble/([0-1])/bitrate/([0-9]+)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&bitrate=$7&player=$8&name=$9 last;
rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(\w+)/noscrobble/([0-1])/transcode_to/(w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&transcode_to=$7&bitrate=$8&player=$9&name=$10 last;
# the following line was needed for me to get downloads of single songs to work
rewrite ^/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/action/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4action=$5&name=$6 last;
location /play {
if (!-e $request_filename) {
rewrite ^/play/art/([^/]+)/([^/]+)/([0-9]+)/thumb([0-9]*)\.([a-z]+)$ /image.php?object_type=$2&object_id=$3&auth=$1 last;
}
rewrite ^/([^/]+)/([^/]+)(/.*)?$ /play/$3?$1=$2;
rewrite ^/(/[^/]+|[^/]+/|/?)$ /play/index.php last;
break;
}
location /rest {
limit_except GET POST {
deny all;
}
}
location ^~ /bin/ {
deny all;
return 403;
}
location ^~ /config/ {
deny all;
return 403;
}
location / {
limit_except GET POST HEAD{
deny all;
}
}
location ~ ^/.*.php {
fastcgi_index index.php;
fastcgi_read_timeout 600s;
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/run/php/php{{ php_version }}-fpm.sock;
}
# Rewrite rule for WebSocket
location /ws {
rewrite ^/ws/(.*) /$1 break;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8100/;
}
}