Skip to content

Commit 1102032

Browse files
committed
Fix #9: Added sync exclude option
1 parent 6a08a54 commit 1102032

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

README.md

+23-18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Optional variables
2020
- `loaddata`: Set to `true` in order to load data from `conf.data`.
2121
- `flush`: Set to `true` in order to flush data before `loaddata`. Depends on `loaddata` variable to be `true`.
2222
- `newrelic`: New Relic license key. Omit to skip New Relic. Recommended to add a default in playbook.
23+
- `exclude`: Additional pattern to exclude from sync, eg. `media/`.
2324

2425
Required Configuration variables
2526
--------------------------------
@@ -52,6 +53,7 @@ Other default variables
5253
- `django_settings`: The Django settings module (.py) to run manage.py from, default: `settings_live`.
5354
- `plesk_server_group`: Plesk server group, default: `psaserv`.
5455
- `plesk_account_group`: Plesk account group, default: `psacln`.
56+
- `sync_opts`: Additional options for rsync. Default: exclude `.*`.
5557

5658
Playbook examples
5759
-----------------
@@ -96,69 +98,72 @@ Task description
9698
8. Open ownership
9799

98100
Open the target directory ownership to allow file copy.
101+
102+
9. Build sync options
99103

100-
9. Sync files
104+
Combine the default `sync_opts` variable with the `exclude` option.
101105

102-
Syncs files to target directory.
106+
10. Sync files
103107

104-
:warning: Make sure that you have synced back any user uploaded files in `media` with manual `rsync`.
108+
Syncs files to target directory.
105109

106-
10. Upgrade pip
110+
:warning: Make sure that you have synced back user uploaded files in `media` with manual `rsync` or use `exclude`.
111+
112+
11. Upgrade pip
107113

108114
Upgrades pip, setup, wheel.
109115

110-
11. Install pip requirements
116+
12. Install pip requirements
111117

112118
Install `requirements.txt` in virtualenv.
113119

114-
12. Set Django admin executable
120+
13. Set Django admin executable
115121

116122
Auxiliary task which sets a variable with the Django admin executable.
117123

118-
13. Set Django admin settings
124+
14. Set Django admin settings
119125

120126
Auxiliary task which sets a variable with the custom settings file (default `django_settings` variable).
121127

122-
14. Migrate
128+
15. Migrate
123129

124130
Runs migrations.
125131

126-
15. Flush data
132+
16. Flush data
127133

128134
Flushes data if `loaddata` and `flush` are both true.
129135

130-
16. Load data
136+
17. Load data
131137

132138
Loads data if `loaddata` is true.
133139

134-
17. Collect static
140+
18. Collect static
135141

136142
Runs collect static.
137143

138-
18. Compile messages
144+
19. Compile messages
139145

140146
Compiles i18n messages if `compile_msgs` is true.
141147

142-
19. Clear cache
148+
20. Clear cache
143149

144150
Clears cache if `memcached` is true.
145151

146-
20. Post deployment script
152+
21. Post deployment script
147153

148154
Runs an optional `post_script`.
149155

150-
21. Close ownership to Plesk account group
156+
22. Close ownership to Plesk account group
151157

152158
Reset target directory ownership to the appropriate Plesk permissions.
153159

154-
22. Close ownership to Plesk server group
160+
23. Close ownership to Plesk server group
155161

156162
Reset target directory ownership to the appropriate Plesk permissions.
157163

158-
23. Configure Apache
164+
24. Configure Apache
159165

160166
Configure Apache to execute the wsgi script using the provided template file.
161167
Only executes if a `domain_name` is provided.
162168
If the configuration changes, causes Plesk to reconfigure the domain in the end (notifies handler).
163169
If the configuration changes, causes Apache to restart in the end (notifies handler).
164-

tasks/main.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@
3737
file: name="{{ conf.host_path }}" owner="{{ ansible_user_id }}" mode=0775 state=directory recurse=yes
3838
become: true
3939

40+
- name: Build sync options
41+
set_fact:
42+
sync_opts_user:
43+
- "--exclude={{ exclude }}"
44+
when: exclude is defined
45+
4046
- name: Sync files
4147
synchronize:
4248
src: "{{ conf.dev_path }}/"
4349
dest: "{{ conf.host_path }}"
4450
delete: yes
45-
rsync_opts:
46-
- "--exclude=.*"
51+
rsync_opts: "{{ sync_opts + sync_opts_user|default([]) }}"
4752

4853
- name: Upgrade pip
4954
pip:

vars/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ plesk_server_group: psaserv
1010

1111
# Plesk account group name
1212
plesk_account_group: psacln
13+
14+
# Additional rsync options
15+
sync_opts:
16+
- "--exclude=.*"

0 commit comments

Comments
 (0)