-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-cronjobs.yml
73 lines (65 loc) · 1.64 KB
/
create-cronjobs.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
- hosts: base_machines
become: yes
become_user: root
vars:
backup_keys:
- backup.key
- backup.secret.key
aws_keys_file: aws_keys.yml
tasks:
- name: Debug AWS keys
debug:
var: aws_keys
- name: Create backup script
template:
src: files/backup.sh.j2
dest: /root/backup.sh
owner: root
mode: u=rwx,g=,o=
- name: Copy keys
copy:
src: "{{ item }}"
dest: "/root"
with_items: "{{ backup_keys }}"
- name: Install backup keys
shell: "gpg --import /root/{{ item }}"
with_items: "{{ backup_keys }}"
- file:
path: "/root/{{ item }}"
state: absent
with_items: "{{ backup_keys }}"
- name: Install Backblaze B2 package
command: "pip install b2==3.9.0"
- name: Copy script to cycle backups
copy:
src: files/cycle_backup_log.sh
dest: /root/cycle_backup_log.sh
owner: root
group: root
mode: "0700"
- cron:
name: "{{ item.name }}"
month: "*"
day: "*"
weekday: "*"
minute: "{{ item.minute }}"
hour: "{{ item.hour }}"
job: "{{ item.job }}"
state: present
loop:
- {
job: "bash /root/backup.sh >> /root/cron.log 2>&1",
name: "Create home directory backups",
hour: "2",
minute: "1",
}
- {
job: "bash /root/cycle_backup_log.sh",
name: "Cycle backups nightly",
hour: "1",
minute: "0",
}
vars_files:
- secure.yml
- aws_keys.yml
- "{{ aws_keys_file }}"