Browse Source

adapt supysonic role for postgress

master
vincent 1 year ago
parent
commit
de8edf36f9
  1. 2
      defaults/main.yml
  2. 4
      meta/main.yml
  3. 25
      tasks/database_mysql.yml
  4. 35
      tasks/database_postgres.yml
  5. 30
      tasks/main.yml
  6. 2
      templates/supysonic.j2

2
defaults/main.yml

@ -11,10 +11,12 @@ exec_group: root
supysonic_repo: https://github.com/spl0k/supysonic.git
supysonic_force_site_update: false
supysonic_repo_branch: master
supysonic_DB_type: postgres # mysql or postgres
supysonic_db_user: supysonic
# Database password, please change when using the role
supysonic_db_password: supysonic
# Database name
supysonic_db_name: supysonic
supysonic_log_level: INFO
gitea_SQl_target_file: []

4
meta/main.yml

@ -55,7 +55,7 @@ galaxy_info:
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies:
- {role: mariadb, become: yes }
dependencies: []
#- {role: mariadb, become: yes }
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

25
tasks/database_mysql.yml

@ -0,0 +1,25 @@
- name: "Ensure database is present"
become: yes
mysql_db:
name: "{{ supysonic_db_name }}"
collation: utf8_general_ci
encoding: utf8
state: present
register: supysonic_database_creation
- name: import DATA in database in case of creation
become: yes
mysql_db:
name: "{{ supysonic_db_name }}"
state: import
target: "{{supysonic_SQl_target_file}}"
when: supysonic_database_creation.changed == true and supysonic_SQl_target_file is defined
- name: "Ensure db user is present"
become: yes
mysql_user:
name: "{{ supysonic_db_user }}"
host: localhost
password: "{{ supysonic_db_password }}"
priv: "{{ supysonic_db_name }}.*:ALL"
state: present

35
tasks/database_postgres.yml

@ -0,0 +1,35 @@
- name: "Ensure db user is present"
become: yes
become_user: postgres
postgresql_user:
name: "{{ supysonic_db_user }}"
password: "{{ supysonic_db_password }}"
state: present
- name: "Ensure database is present"
become: yes
become_user: postgres
postgresql_db:
name: "{{ supysonic_db_name }}"
lc_collate: fr_FR.UTF-8
encoding: utf8
owner: "{{ supysonic_db_user }}"
state: present
register: supysonic_database_creation
- name: add citext extention
become: yes
become_user: postgres
postgresql_ext:
db: "{{ supysonic_db_name }}"
name: "citext"
- name: import DATA in database in case of creation
become: yes
become_user: postgres
postgresql_db:
name: "{{ supysonic_db_name }}"
state: restore
target: "{{supysonic_SQl_target_file}}"
when: supysonic_database_creation.changed == true and supysonic_SQl_target_file is defined

30
tasks/main.yml

@ -1,31 +1,9 @@
---
# tasks file for supysonic
- name: "Ensure database is present"
become: yes
mysql_db:
name: "{{ supysonic_db_name }}"
collation: utf8_general_ci
encoding: utf8
state: present
register: supysonic_database_creation
- name: import DATA in database in case of creation
become: yes
mysql_db:
name: "{{ supysonic_db_name }}"
state: import
target: "{{supysonic_SQl_target_file}}"
when: supysonic_database_creation.changed == true and supysonic_SQl_target_file is defined
- name: "Ensure db user is present"
become: yes
mysql_user:
name: "{{ supysonic_db_user }}"
host: localhost
password: "{{ supysonic_db_password }}"
priv: "{{ supysonic_db_name }}.*:ALL"
state: present
- name: select specific Database tasks
include_tasks: "database_{{supysonic_DB_type}}.yml"
- name: stat location folder
stat:
@ -67,7 +45,9 @@
- name: install sql client
pip:
virtualenv: "{{venv_location}}{{supysonic_venv_name}}" # not required. An optional path to a I(virtualenv) directory to install into. It cannot be specified together with the 'executable' parameter (added in 2.1). If the virtualenv does not exist, it will be created before installing packages. The optional virtualenv_site_packages, virtualenv_command, and virtualenv_python options affect the creation of the virtualenv.
name: pymysql
name:
- pymysql
- psycopg2
- name: apply config template
template:

2
templates/supysonic.j2

@ -2,7 +2,7 @@
; A database URI. See the 'schema' folder for schema creation scripts
; Default: sqlite:////tmp/supysonic/supysonic.db
;database_uri = sqlite:////var/supysonic/supysonic.db
database_uri = mysql://{{supysonic_db_user}}:{{supysonic_db_password}}@localhost/{{supysonic_db_name}}
database_uri = {{supysonic_DB_type}}://{{supysonic_db_user}}:{{supysonic_db_password}}@localhost/{{supysonic_db_name}}
;database_uri = postgres://supysonic:supysonic@localhost/supysonic
; Optional, restrict scanner to these extensions. Default: none

Loading…
Cancel
Save