-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-playbook.yml
73 lines (73 loc) · 1.9 KB
/
angular-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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
- hosts: "{{ machine }}"
become: no
tasks:
# Git and Nginx
- name: Install git, nginx
become: yes
apt:
name:
- git
- nginx
update_cache: yes
# Download repository
- name: Download frontend from repository
git:
dest: angular
repo: https://github.com/spring-petclinic/spring-petclinic-angular.git
clone: yes
force: yes
# Configure repository
- name: Configure REST address
lineinfile:
dest: ./angular/src/environments/environment.prod.ts
regexp: '^\s*REST_API_URL:'
line: "REST_API_URL: 'http://{{ load_balancer_host }}:{{ load_balancer_port }}/petclinic/api/'"
# NodeJS and NPM
- name: Update nodejs information
become: yes
shell:
cmd: curl -sL https://deb.nodesource.com/setup_16.x | bash -
warn: false
- name: Install nodejs, npm
become: yes
apt:
name: nodejs
state: latest
- name: Update npm
become: yes
npm:
name: 'npm'
state: latest
global: yes
- name: Install npm packages
npm:
path: ./angular
- name: Install npm angular
become: yes
npm:
name: '@angular/cli'
version: '11.2.11'
global: yes
# Build angular
- name: Build frontend
become: yes
shell:
cmd: ng build --prod --base-href=/petclinic/ --output-path=/var/www/html/petclinic/
chdir: angular
# Setup Nginx
- name: Remove default nginx config
become: yes
file:
path: /etc/nginx/sites-enabled/default
state: absent
- name: Upload nginx angular config
become: yes
template:
src: ./sent_config/nginx-angular.conf.j2
dest: /etc/nginx/sites-enabled/nginx-angular.conf
# Run
- name: Restart nginx
become: yes
service:
name: nginx
state: restarted