-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
38 lines (34 loc) · 968 Bytes
/
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
---
- hosts: localhost
become: yes
vars:
server_name: "{{ ansible_default_ipv4.address }}"
document_root: /var/www
app_root: /root/html_demo_site-main
tasks:
- name: Update apt cache and install Nginx
apt:
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
copy:
src: files/nginx.conf.j2
dest: /etc/nginx/sites-available/default/nginx.conf
notify: preserve
- name: Enable new site
file:
src: /etc/nginx/sites-available/default/nginx.conf
dest: /etc/nginx/sites-enabled/default/ngnix.conf
state: link
notify: Restart Nginx
handlers:
- name: Restart Nginx
service:
name: nginx
state: restarted