hass/tasks/database_postgres.yml

41 lines
1015 B
YAML
Raw Permalink Normal View History

2020-09-08 19:05:11 +00:00
- name: "Ensure db user is present"
become: yes
become_user: postgres
postgresql_user:
name: "{{ hass_db_user }}"
password: "{{ hass_db_password }}"
state: present
2020-09-21 18:31:05 +00:00
2020-09-08 19:05:11 +00:00
- name: "Ensure database is present"
become: yes
become_user: postgres
postgresql_db:
name: "{{ hass_db_name }}"
lc_collate: fr_FR.UTF-8
encoding: utf8
2020-09-08 21:32:56 +00:00
template: template0
2020-09-08 19:05:11 +00:00
owner: "{{ hass_db_user }}"
state: present
register: hass_database_creation
2020-09-21 18:31:05 +00:00
2020-09-08 19:05:11 +00:00
- 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
2020-09-21 18:31:05 +00:00
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}}"