adapt supysonic role for postgress

This commit is contained in:
vincent 2020-09-06 22:16:56 +02:00
parent 6ecd7c2934
commit de8edf36f9
6 changed files with 70 additions and 28 deletions

View File

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

View File

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

25
tasks/database_mysql.yml Normal file
View File

@ -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

View File

@ -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

View File

@ -1,31 +1,9 @@
--- ---
# tasks file for supysonic # 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 - name: select specific Database tasks
become: yes include_tasks: "database_{{supysonic_DB_type}}.yml"
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: stat location folder - name: stat location folder
stat: stat:
@ -67,7 +45,9 @@
- name: install sql client - name: install sql client
pip: 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. 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 - name: apply config template
template: template:

View File

@ -2,7 +2,7 @@
; A database URI. See the 'schema' folder for schema creation scripts ; A database URI. See the 'schema' folder for schema creation scripts
; Default: sqlite:////tmp/supysonic/supysonic.db ; Default: sqlite:////tmp/supysonic/supysonic.db
;database_uri = sqlite:////var/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 ;database_uri = postgres://supysonic:supysonic@localhost/supysonic
; Optional, restrict scanner to these extensions. Default: none ; Optional, restrict scanner to these extensions. Default: none