-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathemissions-api.yml
More file actions
124 lines (111 loc) · 3.07 KB
/
Copy pathemissions-api.yml
File metadata and controls
124 lines (111 loc) · 3.07 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
- hosts: server
become: yes
vars_files:
- secret-vars.yml
vars:
python_binary: '{% if ansible_os_family == "RedHat"%}python3.8{% else %}python{% endif %}'
tasks:
- name: install needed software
package:
name:
- git
- name: install RedHat specific software
package:
name:
- cmake
- gcc
- make
- libcurl-devel
- python38-devel
- python38
- postgresql12-devel
- openssl-devel
when: ansible_os_family == 'RedHat'
- name: install Debian specific software
package:
name:
- python3
- python3-venv
- python3-dev
- build-essential
- cmake
- libpq-dev
- libssl-dev
- libcurl4-openssl-dev
when: ansible_os_family == 'Debian'
- name: create Emissions-API user
user:
name: emissions-api
system: yes
home: /opt/emissions-api
- name: clone Emissions-API repository
become_user: emissions-api
git:
repo: https://github.com/emissions-api/emissions-api.git
dest: /opt/emissions-api/emissions-api/
update: true
version: main
notify:
restart emissionsapi-web
# Workaround for python h3.
# It is using cmake > 3.1 which is called cmake3 on Amazon Linux 2
- name: link cmake to cmake3
file:
state: link
path: /bin/cmake
src: /bin/cmake3
when: ansible_distribution == "Amazon"
- name: install requirements
pip:
requirements: /opt/emissions-api/emissions-api/requirements.txt
virtualenv: /opt/emissions-api/venv/
virtualenv_command: /usr/bin/{{ python_binary }} -m venv
environment:
PYCURL_SSL_LIBRARY: openssl
PATH: '{{ ansible_env.PATH }}:/usr/pgsql-12/bin'
- name: install Emissions-API config file
template:
dest: /opt/emissions-api/emissions-api/emissionsapi.yml
src: emissions-api/emissionsapi.yml.j2
owner: emissions-api
group: emissions-api
mode: 0600
notify:
restart emissionsapi-web
- name: install systemd files
copy:
dest: /etc/systemd/system/
src: emissions-api/{{ item }}
force: yes
mode: 0644
loop:
- emissionsapi-import.service
- emissionsapi-import.timer
notify:
- reload systemd
- name: install Emissions-API service file
copy:
dest: /etc/systemd/system/
src: emissions-api/emissionsapi-web.service
force: yes
mode: 0644
notify:
- reload systemd
- restart emissionsapi-web
- name: run Emissions-API now and on boot
service:
name: '{{ item }}'
enabled: yes
state: started
with_items:
- emissionsapi-web
- emissionsapi-import.timer
handlers:
- name: reload systemd
systemd:
daemon_reload: yes
- name: restart emissionsapi-web
service:
name: emissionsapi-web
state: restarted