|
230 | 230 |
|
231 | 231 | - name: Set up www site with files.
|
232 | 232 | block:
|
| 233 | + - local_action: |
| 234 | + module: file |
| 235 | + path: www/{{ domain_name }}/{{ item }} |
| 236 | + args: |
| 237 | + state: directory |
| 238 | + with_items: |
| 239 | + - static |
| 240 | + - people |
| 241 | + - files |
| 242 | + become: false |
233 | 243 | # now create dirs under /mnt/docker/www
|
| 244 | + - file: |
| 245 | + path: /mnt/docker/www/files/{{ item.path }} |
| 246 | + state: directory |
| 247 | + recurse: yes |
| 248 | + owner: 991 |
| 249 | + group: 991 |
| 250 | + with_filetree: www/{{ domain_name}}/files |
| 251 | + when: item.state == 'directory' |
| 252 | + - file: |
| 253 | + path: /mnt/docker/www/people/{{ item.path }} |
| 254 | + state: directory |
| 255 | + recurse: yes |
| 256 | + owner: 991 |
| 257 | + group: 991 |
| 258 | + with_filetree: www/{{ domain_name}}/people |
| 259 | + when: item.state == 'directory' |
234 | 260 | - file:
|
235 | 261 | path: /mnt/docker/www/{{ item.path }}
|
236 | 262 | state: directory
|
237 | 263 | recurse: yes
|
238 | 264 | owner: 991
|
239 | 265 | group: 991
|
240 |
| - with_filetree: www/{{ domain_name}} |
| 266 | + with_filetree: www/{{ domain_name}}/static |
241 | 267 | when: item.state == 'directory'
|
242 | 268 |
|
243 | 269 | # list of text files
|
244 | 270 | - local_action:
|
245 | 271 | module: |
|
246 |
| - shell find . -type f | xargs file -i | |
| 272 | + shell find . -type f | egrep -v '^\./static/' | xargs file -i | |
247 | 273 | egrep 'text/plain|text/html' | awk -F: '{print $1}'
|
248 | 274 | args:
|
249 | 275 | chdir: www/{{ domain_name }}
|
250 | 276 | register: web_text_files
|
251 | 277 | changed_when: false
|
| 278 | + |
252 | 279 | # list of binary files
|
253 | 280 | - local_action:
|
254 | 281 | module: |
|
255 |
| - shell find . -type f | xargs file -i | |
| 282 | + shell find . -type f | egrep -v '^./static/' | xargs file -i | |
256 | 283 | egrep -v 'text/plain|text/html' | awk -F: '{print $1}'
|
257 | 284 | args:
|
258 | 285 | chdir: www/{{ domain_name }}
|
259 | 286 | register: web_binary_files
|
260 | 287 | changed_when: false
|
261 | 288 |
|
| 289 | + # list of static files |
| 290 | + - local_action: |
| 291 | + module: | |
| 292 | + shell find . -type f |
| 293 | + args: |
| 294 | + chdir: www/{{ domain_name }}/static |
| 295 | + register: web_static_files |
| 296 | + changed_when: false |
| 297 | + |
262 | 298 | # now create files with template
|
263 | 299 | - name: Update web site text files
|
264 | 300 | template:
|
|
277 | 313 | group: 991
|
278 | 314 | with_items: "{{ web_binary_files.stdout_lines }}"
|
279 | 315 |
|
| 316 | + # Copy the static files |
| 317 | + - name: Update web site static files |
| 318 | + copy: |
| 319 | + src: www/{{ domain_name }}/static/{{ item }} |
| 320 | + dest: /mnt/docker/www/{{ item }} |
| 321 | + owner: 991 |
| 322 | + group: 991 |
| 323 | + with_items: "{{ web_static_files.stdout_lines }}" |
| 324 | + |
280 | 325 | # Now for the website nginx config
|
281 | 326 | - name: Set up the nginx config
|
282 | 327 | template:
|
|
0 commit comments