-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontend-playbook.yml
More file actions
112 lines (96 loc) · 2.73 KB
/
frontend-playbook.yml
File metadata and controls
112 lines (96 loc) · 2.73 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
---
- name: Setup Node.js, Apache, vHost, Directory Structure, SSL and index.html
hosts: all
become: yes
tasks:
- name: Update apt cache
apt:
update_cache: yes
- name: Install curl
apt:
name: curl
state: present
- name: Add NodeSource repo for Node.js 22
shell: curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
args:
executable: /bin/bash
- name: Install Node.js (includes npm)
apt:
name: nodejs
state: present
- name: Install Apache2
apt:
name: apache2
state: present
- name: Install Certbot and Apache plugin
apt:
name:
- certbot
- python3-certbot-apache
state: present
- name: Create base web directory
file:
path: /var/www/pro.stage.webinsights.info
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Create versioned directory 0.0.0
file:
path: /var/www/pro.stage.webinsights.info/0.0.0
state: directory
owner: www-data
group: www-data
mode: '0755'
- name: Create symlink "current" to 0.0.0
file:
src: /var/www/pro.stage.webinsights.info/0.0.0
dest: /var/www/pro.stage.webinsights.info/current
state: link
force: yes
- name: Create index.html in version directory
copy:
dest: /var/www/pro.stage.webinsights.info/0.0.0/index.html
content: |
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>Hello WebInsights</h1>
</body>
</html>
owner: www-data
group: www-data
mode: '0644'
- name: Copy Apache vHost file
copy:
src: files/pro.stage.webinsights.info.conf
dest: /etc/apache2/sites-available/pro.stage.webinsights.info.conf
mode: '0644'
notify: Reload Apache
- name: Enable vHost pro.stage.webinsights.info
command: a2ensite pro.stage.webinsights.info.conf
notify: Reload Apache
- name: Disable default site (optional)
command: a2dissite 000-default.conf
notify: Reload Apache
- name: Ensure Apache is running and enabled
service:
name: apache2
state: started
enabled: yes
- name: Obtain SSL certificate with Certbot
command: >
certbot --apache --non-interactive --agree-tos
--redirect
-m your@email.com
-d pro.stage.webinsights.info
args:
creates: /etc/letsencrypt/live/pro.stage.webinsights.info/fullchain.pem
handlers:
- name: Reload Apache
service:
name: apache2
state: reloaded