This repository has been archived by the owner on Feb 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.yml
95 lines (80 loc) · 2.39 KB
/
app.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
85
86
87
88
89
90
91
92
93
94
95
---
- hosts: webservers
become: true
gather_facts: no
tasks:
- name: Fetch app from GitHub
git:
repo: https://github.com/contino/hello-azure
dest: /app
force: yes
- name: Ensure that application has been copied first
stat:
path: /app
register: application_directory_info
- fail:
msg: "Ensure that the hello-azure application has been copied into this instance first."
when: not application_directory_info.stat.exists
- name: Ensure that environment file is present
stat:
path: "{{ env_file_location }}"
register: environment_file_info
- fail:
msg: "This environment file is missing: {{ env_file_location }}"
when: not environment_file_info.stat.exists
# TODO: move into infra
- name: install pip correctly
package:
name: python-pip
state: present
- name: Install application dependencies
pip:
executable: pip
requirements: /app/requirements.txt
- name: Install hello-azure service
block:
- name: Copy the "hello-azure" systemd unit
template:
src: hello_azure.service.j2
dest: /lib/systemd/system/hello-azure.service
- name: Ensure that the service is started
systemd:
name: hello-azure
state: started
daemon_reload: yes
- name: Copy infrastructure test
copy:
src: tests/webservers_test.yml
dest: /tests/test.yml
- hosts: databases
gather_facts: no
tasks:
- name: Create the database for Hello Azure app
become: true
become_method: su
become_user: postgres
postgresql_db:
name: "{{ lookup('env', 'POSTGRES_DB') }}"
- name: Create the database user
become: true
become_method: su
become_user: postgres
postgresql_user:
db: "{{ lookup('env', 'POSTGRES_DB') }}"
name: "{{ lookup('env', 'POSTGRES_USER') }}"
password: "{{ lookup('env', 'POSTGRES_PASSWORD') }}"
- name: Copy infrastructure test
copy:
src: tests/databases_test.yml
dest: /tests/test.yml
- hosts: all
gather_facts: no
connection: local
tasks:
- name: Restart goss
systemd:
name: goss
state: restarted
- name: Ensure that infrastructure tests are passing
uri:
url: http://localhost:8080/healthz