diff --git a/inventory/host_vars/web4.yml b/inventory/host_vars/web4.yml index 5b5731c..69910a0 100644 --- a/inventory/host_vars/web4.yml +++ b/inventory/host_vars/web4.yml @@ -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 diff --git a/playbooks/webapps.yml b/playbooks/webapps.yml index 46e480b..834362b 100644 --- a/playbooks/webapps.yml +++ b/playbooks/webapps.yml @@ -36,3 +36,10 @@ roles: - role: wordpress tags: [never, wordpress] + +- name: Install libertus webapplications + hosts: web4 + diff: true + roles: + - role: ampache + tags: [never, ampache] diff --git a/roles/ampache/tasks/ampache.yml b/roles/ampache/tasks/ampache.yml new file mode 100644 index 0000000..d93f5ab --- /dev/null +++ b/roles/ampache/tasks/ampache.yml @@ -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" diff --git a/roles/ampache/tasks/db.yml b/roles/ampache/tasks/db.yml new file mode 100644 index 0000000..afbaca7 --- /dev/null +++ b/roles/ampache/tasks/db.yml @@ -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" diff --git a/roles/ampache/tasks/main.yml b/roles/ampache/tasks/main.yml new file mode 100644 index 0000000..22c1e26 --- /dev/null +++ b/roles/ampache/tasks/main.yml @@ -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 diff --git a/roles/ampache/templates/ampache.cfg.php.j2 b/roles/ampache/templates/ampache.cfg.php.j2 new file mode 100644 index 0000000..f2438e0 --- /dev/null +++ b/roles/ampache/templates/ampache.cfg.php.j2 @@ -0,0 +1,1465 @@ +;### +;######################################################### +; General Config # +;######################################################### + +; This value is used to detect if this config file is up to date +; this is compared against a constant called CONFIG_VERSION +; that is located in src/Config/Init/InitializationHandlerConfig.php +config_version = 83 + +; Defines the default timezone used by the date functions +; Uses the same strings as the default date.timezone (https://php.net/date.timezone) +; If not set fallback to date_default_timezone_get() (https://www.php.net/manual/en/function.date-default-timezone-get.php) +; EXAMPLE VALUES: "UTC", "Europe/London", "America/Los_Angeles" (https://www.php.net/manual/en/timezones.php) +; DEFAULT: "UTC" +;date_timezone = "UTC" + +;######################################################### +; Auto Update # +;######################################################### + +; Allow you to hard code a default git branch for Ampache +; If you set this value the inbuilt updater will use this branch for updates. +; POSSIBLE VALUES: master develop patch6 release6 +; DEFAULT: none +;github_force_branch = "develop" + +; This value allows to override the composer binary path to distinguish between multiple composer versions +; Either a binary name in $PATH as well as a fully qualified path is possible +; DEFAULT: composer +;composer_binary_path = "composer" + +; By default Ampache doesn't install dev packages using the --no-dev parameter +; disable this setting to install dev packages (e.g. composer install --prefer-source --no-interaction) +; DEFAULT: "true" +composer_no_dev = "true" + +; This value allows to override the npm binary path to distinguish between multiple npm versions +; Either a binary name in $PATH as well as a fully qualified path is possible +; DEFAULT: npm +;npm_binary_path = "npm" + +; We sometimes need to talk and will show a warning to admin users +; Enable this setting if you don't want to see warnings (When we enable them) +; DEFAULT: "false" +;hide_ampache_messages = "true" + +;######################################################### +; Path Vars # +;######################################################### + +; The public http host of your server. +; If not set, retrieved automatically from client request. +; This setting is required for WebSocket server +; DEFAULT: none +;http_host = "localhost" + +; The public http port of your server. +; If not set, retrieved automatically from client request. +; DEFAULT: none +;http_port = 80 + +; The public path to your Ampache install +; Do not put a trailing / on this path +; For example if your site is located at http://localhost +; than you do not need to enter anything for the web_path +; if it is located at http://localhost/music you need to +; set web_path to /music +; DEFAULT: none +web_path = "" + +; The local http url of your server. +; This is used to access the server from within the +; same host where ampache is running. +; For example, if the ampache server is not +; directly accessed via the public domain but via a reverse +; proxy, local_web_path would need to be changed +; to a localhost URL. +; If not set, retrieved automatically from server information. +; DEFAULT: none +;local_web_path = "http://localhost/ampache" + +; The Ampache base URL is determined from web requests. +; When using CLI actions you don't send a web request meaning +; it can't be determined. This setting allows you to set a +; fallback when the base url can't be determined. Do not put a +; trailing slash or this will not work. +; DEFAULT: none +;fallback_url = "https://example.ampache.dev" + +;######################################################### +; Database # +;######################################################### + +; Hostname of your database +; For socket authentication, set the path to socket file (e.g. /var/run/mysqld/mysqld.sock) +; DEFAULT: localhost +database_hostname = "localhost" + +; Port to use when connecting to your database +; DEFAULT: none +database_port = "" + +; Name of your Ampache database +; DEFAULT: none +database_name = "{{ ampache_maria_database }}" + +; Username for your Ampache database +; DEFAULT: none +database_username = "{{ ampache_maria_user }}" + +; Password for your Ampache database, this can not be blank +; this is a 'forced' security precaution, the default value +; will not work (except if using socket authentication) +; DEFAULT: none +database_password = "{{ ampache_maria_password }}" + +; Set a default charset for your database +; Don't change this unless you understand how to BACKUP and RESTORE a database! +; DEFAULT: "utf8mb4" +;database_charset = "utf8mb4" + +; Set a default collation for your database +; Don't change this unless you understand how to BACKUP and RESTORE a database! +; +; There are a ton of options but you'll probably want one of these. +; "utf8_unicode_ci" = Regular unicode (3 bytes per character) +; "utf8mb4_unicode_ci" = 4 bytes per character +; "utf8mb4_unicode_520_ci" = Supports more characters and is based on UCA 5.2.0 weight keys +; http://www.unicode.org/Public/UCA/5.2.0/allkeys.txt +; DEFAULT: "utf8mb4_unicode_ci" +;database_collation = "utf8mb4_unicode_ci" + +; Set a default table engine for your database +; Don't change this unless you understand how to BACKUP and RESTORE a database! +; DEFAULT: "InnoDB" +;database_engine = "InnoDB" + +;######################################################### +; Session and Security # +;######################################################### + +; Cryptographic secret +; This MUST BE changed with your own secret key. Ampache-specific, just pick any random string you want. +secret_key = "{{ ampache_secret_key }}" + +; Length that a session will last expressed in seconds. Default is +; one hour. +; DEFAULT: 3600 +session_length = 3600 + +; Length that the session for a single streaming instance will last +; the default is two hours. With some clients, and long songs this can +; cause playback to stop, increase this value if you experience that +; DEFAULT: 7200 +stream_length = 7200 + +; This length defines how long a 'remember me' session and cookie will +; last, the default is 86400, same as length. It is up to the administrator +; of the box to increase this, for reference 86400 = 1 day, +; 604800 = 1 week, and 2419200 = 1 month +; DEFAULT: 604800 +remember_length = 604800 + +; Name of the Session/Cookie that will sent to the browser +; If you are using session_cookiesecure add the prefix __Secure- +; to restrict cookie access to HTTPS only (e.g. "__Secure-ampache") +; (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#cookie-namecookie-value) +; DEFAULT: "ampache" +session_name = "ampache" + +; Lifetime of the Cookie, 0 == Forever (until browser close), otherwise in terms of seconds +; If you want cookies to last past a browser close set this to a value in seconds. +; DEFAULT: 0 +session_cookielife = 0 + +; Create cookies with the "secure" flag. +; Set to 1 (true) if you are running a secure site (HTTPS). +; DEFAULT: 0 +session_cookiesecure = 0 + +; Auth Methods +; This defines which auth methods Auth will attempt to use and in which order. +; If auto_create isn't enabled the user must exist locally. +; DEFAULT: mysql +; VALUES: mysql,ldap,http,pam,external +auth_methods = "mysql" + +; External authentication +; This sets the helper used for external authentication. It should conform to +; the interface used by mod_authnz_external +; DEFAULT: none +;external_authenticator = "/usr/sbin/pwauth" + +; Automatic local password updating +; Determines whether successful authentication against an external source +; will result in an update to the password stored in the database. +; A locally stored password is needed for API access. +; DEFAULT: "false" +;auth_password_save = "true" + +; Log out redirection target +; Defaults to our own login.php, but we can override it here if, for instance, +; we want to redirect to an SSO provider instead. +;logout_redirect = "http://sso.example.com/logout" + +; Use Access List +; Toggle this on if you want Ampache to pay attention to the access list +; and only allow streaming/downloading/api-rpc from known hosts api-rpc +; will not work without this on. +; NOTE: Default Behavior is DENY FROM ALL +; DEFAULT: "true" +access_control = "true" + +; Require Session +; If this is set to true Ampache will make sure that the URL passed when +; attempting to retrieve a song contains a valid Session ID This prevents +; others from guessing URL's. This setting is ignored if you have use_auth +; disabled. +; DEFAULT: "true" +require_session = "true" + +; Webplayer Access Level +; Set a minimum access level required to access the webplayer. +; When a user does not meet the access requirements then you +; are blocked from using the webplayer. +; NOTE: This setting is ignored if you disable use_auth +; POSSIBLE VALUES: guest, user, content_manager, manager, admin +; DEFAULT: "user" +webplayer_level = "user" + +; Require LocalNet Session +; If this is set to true then Ampache will require that a valid session +; is passed even on hosts defined in the Local Network ACL. This setting +; has no effect if access_control is not enabled +; DEFAULT: "true" +require_localnet_session = "true" + +; Multiple Logins +; Added by Vlet 07/25/07 +; When this setting is enabled a user may only be logged in from a single +; IP address at any one time, this is to prevent sharing of accounts +; DEFAULT: "false" +;prevent_multiple_logins = "true" + +; Allow Embedding Ampache in Frames +; Whether a browser should be allowed to render a page in a ,