- 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 - 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}}"