-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovisioning.yml
75 lines (57 loc) · 1.88 KB
/
provisioning.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
---
# common
- hosts: all
sudo: yes
gather_facts: no
tasks:
- name: Install nginx.
apt: name={{ item }} state=present update_cache=yes
with_items:
- nginx
- name: Stop Nginx for now.
service: name=nginx state=stopped enabled=yes
# webservers
- hosts: webservers
sudo: yes
tasks:
- name: Install Node and apache.
apt: name={{ item }} state=present update_cache=yes
with_items:
- nodejs
- apache2
- npm
- name: Install Express.
npm: name=express global=true
- name: Make sure Apache is stopped.
service: name=apache2 state=stopped enabled=yes
- name: Make sure nginx is started and configure it to run at boot.
service: name=nginx state=started enabled=yes
- name: Write our nginx.conf.
template: src=templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf
notify: restart nginx
- name: Write our /etc/nginx/sites-available/default.
template: src=templates/default-site.j2 dest=/etc/nginx/sites-available/default
notify: restart nginx
- name: Deploy website content.
template: src=templates/index.html.j2 dest=/usr/share/nginx/html/index.html
handlers:
- name: restart nginx
service: name=nginx state=restarted
# loadbalancer
- hosts: lb
sudo: yes
tasks:
- name: Install HAProxy and socat.
apt: name={{ item }} state=present update_cache=yes
with_items:
- haproxy
- socat
- name: enable haproxy
lineinfile: dest=/etc/default/haproxy regexp="^ENABLED" line="ENABLED=1"
notify: restart haproxy
- name: deploy haproxy config
template: src=templates/haproxy.cfg.j2 dest=/etc/haproxy/haproxy.cfg
notify: restart haproxy
handlers:
- name: restart haproxy
service: name=haproxy state=restarted