-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathuploads.yml
46 lines (40 loc) · 1.72 KB
/
uploads.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
- name: Sync {{ site }} UPLOADS between development <-> {{ env }} environments
hosts: web:&{{ env }}
remote_user: "{{ web_user }}"
vars:
project: "{{ wordpress_sites[site] }}"
project_current: "{{ www_root }}/{{ site }}/current"
project_local_path: "{{ (lookup('env', 'USER') == 'vagrant') | ternary(project_current, project.local_path) }}"
tasks:
- name: Abort if environment variable is equal to development
fail:
msg: "ERROR: development is not a valid environment for this mode (you can't push/pull from development to development)."
when: env == "development"
- name: PULL uploads
block:
- name: Pull uploads from {{ env }}
synchronize:
src: "{{ project_current }}/web/app/uploads/"
dest: "{{ project_local_path }}/web/app/uploads/"
mode: pull
recursive: yes
rsync_opts: --exclude=.DS_Store
- name: Elementor flush CSS on development
connection: local
shell: vagrant ssh -- "cd {{ project_current }} && wp cli has-command 'elementor flush_css' && [ $? -eq 0 ] && wp elementor flush_css --skip-themes || cd ."
when: mode is not defined or mode == "pull"
- name: PUSH uploads
block:
- name: Push uploads to {{ env }}
synchronize:
src: "{{ project_local_path }}/web/app/uploads/"
dest: "{{ project_current }}/web/app/uploads/"
mode: push
recursive: yes
rsync_opts: --exclude=.DS_Store
- name: Elementor flush CSS on {{ env }}
shell: wp cli has-command 'elementor flush_css' && [ $? -eq 0 ] && wp elementor flush_css --skip-themes || cd .
args:
chdir: "{{ project_current }}"
when: mode is defined and mode == "push"