deploy/dump_db.yml
author ymh <ymh.work@gmail.com>
Mon, 09 Dec 2019 11:32:04 +0100
changeset 7 81d22971b333
parent 0 505fe5249d9c
permissions -rw-r--r--
adding missing wp-config file

# 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