-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnup_play.yml
85 lines (74 loc) · 2.54 KB
/
fnup_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
- import_playbook: common_play.yml
- hosts: '{{ target_hosts | default("tag_service_fnup", true) }}'
remote_user: "{{ my_remote_user }}"
become: yes
vars:
local_fnup_path_tar_gz: /Volumes/Projects/Dev_Team/backups/fnup_vagrant_sample.tar.gz
local_vpail_path_tar_gz: /Volumes/Projects/Dev_Team/images/images_sample.tar.gz
vars_files:
- vars/common_vars.yml
- vars/fnup_vars.yml
handlers:
- include_tasks: handlers/main.yml
tasks:
- name: allow writes in html root
file:
path: "{{ static_dir }}"
group: www-data
owner: www-data
recurse: yes
state: directory
- name: dir for webdav tmp
file:
path: "{{ static_dir_root }}/tmp"
group: www-data
owner: www-data
mode: 0775
state: directory
- name: config nginx
include_role:
name: nginx
- 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
"{{ static_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: 'fnup'
source_s3_sync_dir: '{{ static_dir }}'
when: use_aws and ec2_tag_cluster == 'prod'
- name: restore backup from s3
shell: >
/usr/bin/aws s3 sync
"s3://{{ s3_sync_bucket_name }}/{{ ec2_tag_cluster }}/{{ s3_sync_prefix }}"
"{{ static_dir }}"
2>&1 | logger -t "[s3 backup initial restore]"
vars:
s3_sync_bucket_name: '{{ s3_backup_bucket_name }}'
s3_sync_prefix: 'fnup'
source_s3_sync_dir: '{{ static_dir }}'
when: use_aws and ec2_tag_cluster == 'prod'
- name: unarchive local fnup backup tar.gz
unarchive:
src: '{{ local_fnup_path_tar_gz }}'
dest: '{{ static_dir }}'
owner: 'www-data'
group: 'www-data'
when: ec2_tag_cluster != 'prod' and ( local_fnup_path_tar_gz is defined )
- import_playbook: backup_play.yml
# TODO: REMOVE ME! when testing is done
#- name: unarchive local vpail sample tar.gz
# unarchive:
# src: '{{ local_vpail_path_tar_gz }}'
# dest: '{{ static_dir }}/cdn'
# owner: 'www-data'
# group: 'www-data'
# when: ec2_tag_cluster != 'prod' and ( local_fnup_path_tar_gz is defined )