corect database issue

This commit is contained in:
vincent 2020-09-21 20:31:05 +02:00
parent 2ed1d4d464
commit ab957eaa03
3 changed files with 25 additions and 2 deletions

View File

@ -2,10 +2,15 @@
# defaults file for hass # defaults file for hass
hass_python_package: hass_python_package:
- mysqlclient
- homeassistant - homeassistant
- myjdapi - myjdapi
hass_python_postgres_package:
- psycopg2 - psycopg2
hass_python_Mysql_package:
- mysqlclient
hass_conf_folder: /var/lib/hass hass_conf_folder: /var/lib/hass
hass_venv_location: /opt/venv/hass hass_venv_location: /opt/venv/hass
hass_db_type: postgres #postgres or mysql hass_db_type: postgres #postgres or mysql

View File

@ -25,3 +25,11 @@
password: "{{ hass_db_password }}" password: "{{ hass_db_password }}"
priv: "{{ hass_db_name }}.*:ALL" priv: "{{ hass_db_name }}.*:ALL"
state: present state: present
- name: install Mysql python module
pip:
name: "{{hass_python_Mysql_package}}"
virtualenv: "{{hass_venv_location}}"
virtualenv_command: /usr/bin/python -m venv
become: true
become_user: "{{hass_username}}"

View File

@ -6,6 +6,7 @@
password: "{{ hass_db_password }}" password: "{{ hass_db_password }}"
state: present state: present
- name: "Ensure database is present" - name: "Ensure database is present"
become: yes become: yes
become_user: postgres become_user: postgres
@ -19,6 +20,7 @@
register: hass_database_creation register: hass_database_creation
- name: import DATA in database in case of creation - name: import DATA in database in case of creation
become: yes become: yes
become_user: postgres become_user: postgres
@ -28,3 +30,11 @@
target: "{{ hass_SQl_target_file }}" target: "{{ hass_SQl_target_file }}"
register: hass_database_import register: hass_database_import
when: hass_database_creation.changed == true and hass_SQl_target_file is defined when: hass_database_creation.changed == true and hass_SQl_target_file is defined
- name: install postgres python module
pip:
name: "{{hass_python_postgres_package}}"
virtualenv: "{{hass_venv_location}}"
virtualenv_command: /usr/bin/python -m venv
become: true
become_user: "{{hass_username}}"