postgress hass
This commit is contained in:
parent
265a7dfe84
commit
c1d05ea9bc
@ -7,6 +7,7 @@ hass_python_package:
|
||||
- myjdapi
|
||||
hass_conf_folder: /var/lib/hass
|
||||
hass_venv_location: /opt/venv/hass
|
||||
hass_db_type: postgres #postgres or mysql
|
||||
hass_db_name: hass
|
||||
hass_db_user: hass
|
||||
hass_SQl_target_file: /
|
||||
|
27
tasks/database_mysql.yml
Normal file
27
tasks/database_mysql.yml
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
- name: "Ensure database is present"
|
||||
become: yes
|
||||
mysql_db:
|
||||
name: "{{ hass_db_name }}"
|
||||
collation: utf8mb4_unicode_ci
|
||||
encoding: utf8mb4
|
||||
state: present
|
||||
register: hass_database_creation
|
||||
|
||||
|
||||
- name: import DATA in database in case of creation
|
||||
become: yes
|
||||
mysql_db:
|
||||
name: "{{ hass_db_name }}"
|
||||
state: import
|
||||
target: "{{ hass_SQl_target_file }}"
|
||||
when: hass_database_creation.changed == true and hass_SQl_target_file is defined
|
||||
|
||||
- name: "Ensure db user is present"
|
||||
become: yes
|
||||
mysql_user:
|
||||
name: "{{ hass_db_user }}"
|
||||
host: localhost
|
||||
password: "{{ hass_db_password }}"
|
||||
priv: "{{ hass_db_name }}.*:ALL"
|
||||
state: present
|
29
tasks/database_postgres.yml
Normal file
29
tasks/database_postgres.yml
Normal file
@ -0,0 +1,29 @@
|
||||
- name: "Ensure db user is present"
|
||||
become: yes
|
||||
become_user: postgres
|
||||
postgresql_user:
|
||||
name: "{{ hass_db_user }}"
|
||||
password: "{{ hass_db_password }}"
|
||||
state: present
|
||||
|
||||
- name: "Ensure database is present"
|
||||
become: yes
|
||||
become_user: postgres
|
||||
postgresql_db:
|
||||
name: "{{ hass_db_name }}"
|
||||
lc_collate: fr_FR.UTF-8
|
||||
encoding: utf8
|
||||
owner: "{{ hass_db_user }}"
|
||||
state: present
|
||||
register: hass_database_creation
|
||||
|
||||
|
||||
- name: import DATA in database in case of creation
|
||||
become: yes
|
||||
become_user: postgres
|
||||
postgresql_db:
|
||||
name: "{{ hass_db_name }}"
|
||||
state: restore
|
||||
target: "{{ hass_SQl_target_file }}"
|
||||
register: hass_database_import
|
||||
when: hass_database_creation.changed == true and hass_SQl_target_file is defined
|
@ -1,32 +1,13 @@
|
||||
---
|
||||
# tasks file for hass
|
||||
|
||||
- name: "Ensure database is present"
|
||||
become: yes
|
||||
mysql_db:
|
||||
name: "{{ hass_db_name }}"
|
||||
collation: utf8mb4_unicode_ci
|
||||
encoding: utf8mb4
|
||||
state: present
|
||||
register: hass_database_creation
|
||||
|
||||
|
||||
- name: import DATA in database in case of creation
|
||||
become: yes
|
||||
mysql_db:
|
||||
name: "{{ hass_db_name }}"
|
||||
state: import
|
||||
target: "{{ hass_SQl_target_file }}"
|
||||
when: hass_database_creation.changed == true and hass_SQl_target_file is defined
|
||||
- name: select specific Database tasks
|
||||
include_tasks: "database_{{hass_db_type}}.yml"
|
||||
|
||||
|
||||
|
||||
- name: "Ensure db user is present"
|
||||
become: yes
|
||||
mysql_user:
|
||||
name: "{{ hass_db_user }}"
|
||||
host: localhost
|
||||
password: "{{ hass_db_password }}"
|
||||
priv: "{{ hass_db_name }}.*:ALL"
|
||||
state: present
|
||||
|
||||
- name: create hass user
|
||||
become: yes
|
||||
|
Loading…
Reference in New Issue
Block a user