---
# Copies specified database dump file and imports it into the database defined
# by db_name.
#
# Available variables:
#  - database_import_filename: Base filename for dump file.
#  - database_import_directory: Path to directory containing dump file.
#    Either absolute or relative to the directory containing the primary playbook.
#
# @todo: improve file path handling: combine filename / path.

# Check whether database dump file is declared.
- name: Define do_db_import.
  set_fact:
    do_db_import: "{{ database_import_filename is defined }}"
  when: do_db_import is not defined
  ignore_errors: yes

# Copy dump file to remote node.
- name: Copy database dump file to remote.
  copy:
    src: "{{ database_import_filename }}"
    dest: /tmp
  when: do_db_import
  register: db_copy_result

# Import dumpfile into database.
- name: Import database.
  mysql_db:
    name: "{{ db_name }}"
    state: import
    target: "/tmp/{{ database_import_filename | basename }}"
  when: do_db_import and db_copy_result is defined and db_copy_result.state == "file"

---
# Copies specified database dump file and imports it into the database defined
# by db_name.
#
# Available variables:
#  - database_import_filename: Base filename for dump file.
#  - database_import_directory: Path to directory containing dump file.
#    Either absolute or relative to the directory containing the primary playbook.
#
# @todo: improve file path handling: combine filename / path.

# Check whether database dump file is declared.
- name: Define do_db_import.
  set_fact:
    do_db_import: "{{ database_import_filename is defined }}"
  when: do_db_import is not defined
  ignore_errors: yes

# Copy dump file to remote node.
- name: Copy database dump file to remote.
  copy:
    src: "{{ database_import_filename }}"
    dest: /tmp
  when: do_db_import
  register: db_copy_result

# Import dumpfile into database.
- name: Import database.
  mysql_db:
    name: "{{ db_name }}"
    state: import
    target: "/tmp/{{ database_import_filename | basename }}"
  when: do_db_import and db_copy_result is defined and db_copy_result.state == "file"

- name: Run `wp search-replace`
  become: no
  command: |
    wp
    --path='{{ web_app_web_root }}'
    search-replace
    '{{ prod_domain }}'
    '{{ local_domain }}'
  when: do_db_import and project_type == 'wordpress'

Add task to run `wp search-replace`
Add task to run `wp search-replace`