-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwww2_play.yml
66 lines (58 loc) · 2.01 KB
/
www2_play.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
- import_playbook: common_play.yml
- hosts: '{{ target_hosts | default("tag_service_www2", true) }}'
remote_user: "{{ my_remote_user }}"
become: yes
vars:
local_www2_path_tar_gz: /Volumes/Projects/Dev_Team/backups/www2_vagrant_sample.tar.gz
vars_files:
- vars/common_vars.yml
- vars/www2_vars.yml
handlers:
- include_tasks: handlers/main.yml
tasks:
- name: config nginx
include_role:
name: nginx
- name: run initial s3 sync for www2 certs, pull from s3 bak
shell: >
/usr/bin/aws s3 sync
"s3://{{ s3_sync_bucket_name }}/{{ ec2_tag_cluster }}/{{ s3_sync_prefix }}"
"{{ source_s3_sync_dir }}/"
2>&1 | logger -t "[s3 sync INITIAL]"
vars:
s3_sync_bucket_name: '{{ s3_backup_bucket_name }}'
s3_sync_prefix: 'www2'
source_s3_sync_dir: '{{ static_dir }}'
when: ec2_tag_cluster == 'prod'
- name: chown '{{ static_dir_root }}'
file:
path: '{{ static_dir_root }}'
state: directory
recurse: yes
owner: www-data
group: www-data
- name: set cronjob for s3 sync bak(static_dir->s3)
cron:
name: "s3 sync for {{ source_s3_sync_dir }}"
user: "{{ cronjob_owner | mandatory}}"
special_time: daily
state: present
job: >
/usr/bin/aws s3 sync
"{{ source_s3_sync_dir }}"
"s3://{{ s3_sync_bucket_name }}/{{ ec2_tag_cluster}}/{{ s3_sync_prefix }}"
2>&1 | logger -t "[s3 sync]"
vars:
s3_sync_bucket_name: '{{ s3_backup_bucket_name }}'
s3_sync_prefix: 'www2'
source_s3_sync_dir: '{{ static_dir }}'
when: use_aws and ec2_tag_cluster == 'prod'
- name: unarchive local www2 backup tar.gz
unarchive:
src: '{{ local_www2_path_tar_gz }}'
dest: '{{ static_dir }}'
owner: 'www-data'
group: 'www-data'
when: ec2_tag_cluster != 'prod' and ( local_www2_path_tar_gz is defined )
- import_playbook: backup_play.yml