---
- name: "Triggering restore of {{ database_engine }} databases from server {{ database_server }}" # noqa command-instead-of-shell no-changed-when
  become: true
  shell: "/root/restore.sh {{ stage }} {{ database_server }}"

- name: "Check for test data on mariadb"
  block:
    - name: "Querying mariadb ..."
      become: true
      become_user: root
      community.mysql.mysql_query:
        login_unix_socket: /run/mysqld/mysqld.sock
        login_db: dummytestdb
        query: SELECT movie FROM movie_quotes WHERE quote = %s
        positional_args:
          - "Shall we play"
      register: query_output

    - name: "Compare query result with given parameters ..."
      assert:
        that:
          - 'query_output.query_result | first | selectattr("movie","match","wargames") | length == 1'

  when:
    - database_engine == 'maria'
