-
Notifications
You must be signed in to change notification settings - Fork 15
/
apiservers.yml
133 lines (119 loc) · 4.37 KB
/
apiservers.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
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
125
126
127
128
129
130
131
132
133
# file: apiservers.yml
#
---
- hosts: api
roles:
# ansible-galaxy install geerlingguy.nodejs
- { role: geerlingguy.nodejs, become: yes }
# ansible-galaxy install Oefenweb.yarn
- { role: Oefenweb.yarn, become: yes }
vars:
nodejs_version: "10.x"
nodejs_npm_global_packages:
- bunyan
- pm2
rciam_api:
name: vomembers-api
port: 8080
path: /srv/comanage-registry-simple-membership-api/VoMembers/v1
repo_url: https://github.com/grnet/comanage-registry-simple-membership-api.git
repo_version: devel
user:
name: rciam-comanage-registry-api
group: rciam-comanage-registry-api
gecos: "RCIAM COmanage Registry API Server,,,"
shell: /bin/bash
home: /srv/comanage-registry-simple-membership-api
tasks:
- name: Ensure RCIAM API dependencies are installed
apt:
name:
- git
state: present
install_recommends: no
update_cache: yes
cache_valid_time: 86400
become: yes
- name: Ensure RCIAM COmanage Registry API group exists
group:
name: "{{ rciam_api.user.group }}"
system: yes
become: yes
- name: Ensure RCIAM COmanage Registry API user exists
user:
name: "{{ rciam_api.user.name }}"
groups: "{{ rciam_api.user.group }}"
comment: "{{ rciam_api.user.gecos }}"
shell: "{{ rciam_api.user.shell }}"
home: "{{ rciam_api.user.home }}"
system: yes
create_home: yes
skeleton: "/empty"
become: yes
- name: Ensure RCIAM COmanage Registry API code checkout directory exists
file:
path: "{{ rciam_api.path }}"
owner: "{{ rciam_api.user.name }}"
group: "{{ rciam_api.user.group }}"
state: directory
become: yes
- name: Ensure RCIAM COmanage Registry API code checkout is up-to-date
git:
repo: "{{ rciam_api.repo_url }}"
dest: "{{ rciam_api.path }}"
version: "{{ rciam_api.repo_version }}"
become: yes
become_user: "{{ rciam_api.user.name }}"
notify: Restart RCIAM COmanage Registry API processes
# TODO- name: Ensure RCIAM COmanage Registry API current symlink to code checkout directory exists
# file:
# src: "{{ rciam_api.path }}"
# path: "{{ rciam_api.path }}/current"
# owner: "{{ rciam_api.user.name }}"
# group: "{{ rciam_api.user.group }}"
# state: link
# become: yes
- name: Ensure RCIAM COmanage Registry API is configured
template:
src: "{{ playbook_dir }}/templates/comanage-registry-simple-membership-api/settings.js.j2"
dest: "{{ rciam_api.path }}/settings.js"
owner: "{{ rciam_api.user.name }}"
group: "{{ rciam_api.user.group }}"
mode: 0400
backup: yes
become: yes
notify: Restart RCIAM COmanage Registry API processes
- name: Ensure RCIAM COmanage Registry API packages are installed
yarn:
path: "{{ rciam_api.path }}"
production: yes
become: yes
become_user: "{{ rciam_api.user.name }}"
handlers:
- name: Delete existing RCIAM COmanage Registry API pm2 processes if running
command:
cmd: "/usr/local/lib/npm/bin/pm2 delete {{ rciam_api.name }}"
chdir: "{{ rciam_api.path }}"
ignore_errors: yes
become: yes
become_user: "{{ rciam_api.user.name }}"
listen: Restart RCIAM COmanage Registry API processes
- name: Ensure RCIAM COmanage Registry API pm2 processes are running
command:
cmd: "/usr/local/lib/npm/bin/pm2 start server.js -i 2 --name {{ rciam_api.name }}"
chdir: "{{ rciam_api.path }}"
become: yes
become_user: "{{ rciam_api.user.name }}"
listen: Restart RCIAM COmanage Registry API processes
- name: Ensure RCIAM COmanage Registry API init script exists
command:
cmd: "/usr/local/lib/npm/lib/node_modules/pm2/bin/pm2 startup systemd -u {{ rciam_api.user.name }} --hp {{ rciam_api.user.home }}"
become: yes
listen: Restart RCIAM COmanage Registry API processes
- name: Ensure RCIAM COmanage Registry API process list is saved
command:
cmd: "/usr/local/lib/npm/lib/node_modules/pm2/bin/pm2 save"
chdir: "{{ rciam_api.path }}"
become: yes
become_user: "{{ rciam_api.user.name }}"
listen: Restart RCIAM COmanage Registry API processes