---
- 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 postgres"
  block:
    - name: "Querying postgres ..."
      become: true
      become_user: postgres
      community.postgresql.postgresql_query:
        db: dummytestdb
        query: SELECT movie FROM movie_quotes WHERE quote = %(quote_val)s
        named_args:
          quote_val: "Shall we play"
      register: query_output

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

  when:
    - database_engine == 'postgres'
