-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_app.yml
More file actions
79 lines (68 loc) · 2.45 KB
/
03_app.yml
File metadata and controls
79 lines (68 loc) · 2.45 KB
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
- name: Deploy the bot/app/worker on remote host
hosts: intbot_app
tasks:
- name: Clone the repository to a specific version (to a temp location)
ansible.builtin.git:
repo: "{{ repository_url }}"
dest: /tmp/src
accept_hostkey: true
version: "{{ app_version }}"
- name: Build with a given commit hash
# This will be stored in local registry, and available as version to docker-compose
# where we can just reference correct version
ansible.builtin.command:
chdir: /tmp/src
cmd: "/usr/bin/make docker/build V={{ app_version }}"
register: output
changed_when: output.rc != 0
failed_when: output.rc != 0
- name: Create a server Makefile to manage app tasks
ansible.builtin.template:
src: app/Makefile.app.j2
dest: ./Makefile
mode: "0640"
- name: Set up docker-compose.yml for the app
ansible.builtin.template:
src: app/docker-compose.app.yml.j2
dest: ./docker-compose.yml
mode: "0640"
- name: Copy env file example
ansible.builtin.copy:
src: ../templates/app/intbot.env.example
dest: intbot.env.example
mode: "0640"
- name: Check if the env file exists
ansible.builtin.stat:
path: intbot.env
register: env_file
- name: If env file doesn't exist - copy the example
ansible.builtin.copy:
src: app/intbot.env.example
dest: intbot.env.example
mode: "0644"
when: not env_file.stat.exists
- name: If the env file doesn't exist - fail with error message
ansible.builtin.fail:
msg: "The env file doesn't exist. Please ssh, copy the example and adjust"
when: not env_file.stat.exists
- name: Start docker compose to see if everything is running
ansible.builtin.command:
chdir: "{{ ansible_user_dir }}"
cmd: "docker compose up -d"
register: output
changed_when: output.rc != 0
failed_when: output.rc != 0
- name: Migrate on prod
ansible.builtin.command:
chdir: "{{ ansible_user_dir }}"
cmd: "/usr/bin/make prod/migrate"
register: output
changed_when: output.rc != 0
failed_when: output.rc != 0
- name: Restart everything and finish
ansible.builtin.command:
chdir: "{{ ansible_user_dir }}"
cmd: "docker compose up -d"
register: output
changed_when: output.rc != 0
failed_when: output.rc != 0