deploy/dump_db.yml
author ymh <ymh.work@gmail.com>
Fri, 06 Dec 2019 01:17:52 +0100
changeset 6 6c5696673f1c
parent 0 505fe5249d9c
permissions -rw-r--r--
Added tag 0.3 for changeset 170e0b52c451

# 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