# vendor/bin/wp option delete _site_transient_update_themes
# vendor/bin/wp option delete _site_transient_theme_roots

- hosts: remote
  vars:
    src_dir: "{{playbook_dir}}/build/tmp/rc/src/"
  tasks:

    - name: create temporary file
      tempfile:
        state: file
        suffix: sql
      register: sql_tmp_path

    - name: dump and fetch
      block:
        - name: dump database
          command:
            argv:
              - "{{remote_path}}/vendor/bin/wp"
              - db
              - export
              - "{{sql_tmp_path.path}}"
          args:
            chdir: "{{remote_path}}"

        - name: transfer sql file
          fetch:
            src: "{{sql_tmp_path.path}}"
            dest: "{{db_file_path}}"
            flat: yes
      always:
        - name: delete temporary file
          file:
            path: "{{sql_tmp_path.path}}"
            state: absent

