-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.yml
44 lines (39 loc) · 1010 Bytes
/
play.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
---
- hosts: all
become: yes
vars:
server_name: "{{ ansible_default_ipv4.address }}"
document_root: /var/www
app_root: html_demo_site-main
tasks:
- name: Update apt cache and install Nginx
dnf:
name: nginx
state: latest
update_cache: yes
- name: Copy website files to the server's document root
copy:
src: "{{ app_root }}"
dest: "{{ document_root }}"
mode: preserve
- name: Apply Nginx template
template:
src: files/nginx.conf.j2
dest: /etc/nginx/sites-available/default
notify: Restart Nginx
- name: Enable new site
file:
src: /etc/nginx/sites-available/default
dest: /etc/nginx/sites-enabled/default
state: link
notify: Restart Nginx
- name: Allow all access to tcp port 80
ufw:
rule: allow
port: '80'
proto: tcp
handlers:
- name: Restart Nginx
service:
name: nginx
state: restarted