forked from matiasdecarli/democracyos_onpremises
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaybook.yml
56 lines (52 loc) · 1.93 KB
/
playbook.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
---
- hosts: host
become: yes
become_user: root
# Default Vars
vars:
- hostDest: /usr/src
- appLocation: ../docker
- democracyos_image: democracyos/democracyos:latest
- backupFolder: /usr/src/backups
- databaseName: democracyos
vars_files:
- 'inventories/{{ inventory_env }}.yml'
roles:
- { role: angstwad.docker_ubuntu, become: yes, become_user: root, when: ansible_distribution == "Debian" }
- { role: angstwad.docker_ubuntu, become: yes, become_user: root, when: ansible_distribution == "Ubuntu" }
- { role: abaez.docker, become: yes, become_user: root, when: ansible_distribution == "CentOS" or ansible_distribution == "Red Hat Enterprise Linux" }
tasks:
-
name: Create "src" folder
file: path={{ hostDest }} state=directory mode=0600
-
name: Copy Compose file to Target
template:
src: templates/docker-compose.j2
dest: "{{ hostDest }}/docker-compose.yml"
-
name: Create a folder to MongoDB
file: path={{ hostDest }}/mongodb state=directory mode=776
-
name: Start Docker Compose
command: docker-compose -f {{ hostDest }}/docker-compose.yml up -d
-
name: Copy cronfile to Backup MongoDB files (Only for production)
template:
src: "templates/backup.j2"
dest: "{{ hostDest }}/backup.sh"
when: ENV == "production" or ENV == "staging"
-
name: Create a folder to MongoDB Backups
file: path={{ backupFolder }} state=directory mode=0600
when: ENV == "production" or ENV == "staging"
-
name: Set cron. Everyday at 23.59 (Only for production)
cron: name="backup mongo" minute="59" hour="23" job="{{ hostDest }}/backup.sh"
when: ENV == "production" or ENV == "staging"
-
name: "Set cron. Run `docker prune --all` every hour."
cron:
name: "Docker System Prune"
special_time: hourly
job: "/usr/bin/docker system prune --all --force"