deploy/deploy_db.yml
author ymh <ymh.work@gmail.com>
Fri, 05 Mar 2021 17:06:11 +0100
changeset 41 8097809b86e6
parent 20 36bdc6e0deb1
permissions -rw-r--r--
Update deploy playbook, add db migration

# 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: transfer sql file
      copy:
        src: "{{db_file_path}}"
        dest: "{{sql_tmp_path.path}}"

    - name: load database
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - db
          - import
          - "{{sql_tmp_path.path}}"
      args:
        chdir: "{{remote_path}}"

    - name: delete temporary file
      file:
        path: "{{sql_tmp_path.path}}"
        state: absent

    - name: search and replace url
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - search-replace
          - "{{origin_url}}"
          - "{{rc_wp_home}}"
      args:
        chdir: "{{remote_path}}"

    - name: set template_root
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - option
          - set
          - template_root
          - "{{remote_path}}/web/wp/wp-content/themes"
      args:
        chdir: "{{remote_path}}"

    - name: delete _site_transient_update_themes option
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - option
          - delete
          - _site_transient_update_themes
      args:
        chdir: "{{remote_path}}"

    - name: delete _site_transient_theme_roots option
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - option
          - delete
          - _site_transient_theme_roots
      args:
        chdir: "{{remote_path}}"

    - name: Set site in french
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - site
          - switch-language
          - fr_FR
      args:
        chdir: "{{remote_path}}"


    - name: update admin password
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - user
          - update
          - "{{rc_admin_user_id}}"
          - "--user_pass={{rc_admin_user_pswd}}"
          - --skip-email
      args:
        chdir: "{{remote_path}}"

    - name: update admin language
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - user
          - update
          - "{{rc_admin_user_id}}"
          - "--locale=en_US"
          - --skip-email
      args:
        chdir: "{{remote_path}}"

    - name: flush cache
      command:
        argv:
          - "{{remote_path}}/vendor/bin/wp"
          - cache
          - flush
      args:
        chdir: "{{remote_path}}"