-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.yml
166 lines (142 loc) · 3.43 KB
/
main.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
---
# Bad ansible! This playbook is an example of poor/bad practices!
# Bad practices may include:
#
# Poor formatting and structure
# Poor use of YAML - but good enough to parse
# Inconsistent style
# Incorrect use of modules
# Poor module choice
# Unclear names
# Hard coding / poor use of variables
# Roles - what are roles?
# Bare variables
# No use of handlers
- name: common configuration
hosts: all
gather_facts: false # remove later! speeds up testing
become: true
tags:
- common
roles:
- { name: common }
# tasks:
# - name: enable repos
# template:
# src: ./open_three-tier-app.repo
# dest: /etc/yum.repos.d/open_three-tier-app.repo
# mode: 0644
- name: deploy haproxy
hosts: frontends
gather_facts: false # remove later! speeds up testing
become: true
tasks:
- name: http
package:
name: haproxy #httpie
state: latest
- name: install HAProxy
yum:
name=haproxy state=latest
- name: enable HAProxy
service:
name: haproxy
state: started
- name: configure haproxy
template:
src: ./haproxy.cfg.j2
dest: /etc/haproxy/haproxy.cfg
- name: restart HAproxy
service:
name: haproxy
state: restarted
- name: deploy tomcat
hosts: apps
gather_facts: false
become: true
tasks:
- name: install tomcat
package:
name: tomcat
state: latest
- name: enable tomcat at boot
service:
name: tomcat
enabled: yes
- name: create ansible tomcat directory
file:
path: /usr/share/tomcat/webapps/ROOT
state: directory
- name: copy static index.html to tomcat webapps/ansible/index.html
template:
src: index.html.j2
dest: /usr/share/tomcat/webapps/ROOT/index.html
mode: 0644
- name: start tomcat
service:
name: tomcat
state: started
- name: index.html on app 1
hosts: app1
gather_facts: false
become: true
tasks:
- name: copy static index.html to tomcat webapps/ansible/index.html
template:
src: index.html.app1
dest: /usr/share/tomcat/webapps/ansible/index.html
- name: index.html on app 1
hosts: app2
gather_facts: false
become: true
tasks:
- name: copy static index.html to tomcat webapps/ansible/index.html
template:
src: index.html.app2
dest: /usr/share/tomcat/webapps/ansible/index.html
- name: deploy postgres
hosts: apps
gather_facts: false
become: true
hosts: appdbs
tasks:
#REMOVIDO BY FABIO - name: install progress
# command: "yum install -y postgresql-server"
- name: install postgres
yum:
name: postgresql-server
state: latest
- name: enable postgressql at boot
service:
name: postgresql
enabled: yes
- name: tell user to finish setting up postgres
debug:
msg: "Either uncomment the postgres setup or manually login and initialize"
# only run the next 2 tasks once!
# - name: initilize postgres
# command: postgresql-setup initdb
# - name: initilize postgres some more
# command: chkconfig postgresql on
- name: start postgres
service:
name: postgresql.service
state: started
- name: deploy apache
hosts: apps
gather_facts: false
become: true
hosts: apps
tasks:
- name: install apache
yum:
name: httpd
state: latest
- name: enable apache at boot
service:
name: httpd
enabled: yes
# - name: start apache
# service:
# name: httpd
# state: started