-
Notifications
You must be signed in to change notification settings - Fork 27
/
site.yml
180 lines (153 loc) · 4.31 KB
/
site.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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
---
- hosts: elkservers
gather_facts: yes
pre_tasks:
- name: update apt cache if needed
become: yes
apt:
update_cache=yes
cache_valid_time=3600
tasks:
- name: Install Java Runtime Environment
become: yes
apt:
name: default-jre
state: present
- hosts: elkservers
gather_facts: no
tasks:
- name: Download Elastic Deb Package
get_url:
url: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.8.1-amd64.deb
dest: /tmp
- name: Install Elastic Deb Package
become: yes
apt:
deb: /tmp/elasticsearch-7.8.1-amd64.deb
- name: Update Elastic Config (IP Address to 0.0.0.0)
become: yes
lineinfile:
destfile: /etc/elasticsearch/elasticsearch.yml
regexp: 'network.host'
line: 'network.host: 0.0.0.0'
- name: Updating Elastic Config (Port Number)
become: yes
lineinfile:
destfile: /etc/elasticsearch/elasticsearch.yml
regexp: 'http.port'
line: 'http.port: 9200'
- name: Updating Elastic Config (Node Name)
become: yes
lineinfile:
destfile: /etc/elasticsearch/elasticsearch.yml
regexp: '#node.name: node-1'
line: 'node.name: node-1'
- name: Updating Elastic Config (Cluster Initial Master Nodes)
become: yes
lineinfile:
destfile: /etc/elasticsearch/elasticsearch.yml
line: 'cluster.initial_master_nodes: ["node-1"]'
- name: Start ElasticSearch Service
become: yes
service:
name: elasticsearch
state: started
- hosts: elkservers
gather_facts: no
tasks:
- name: Download Kibana Deb Package
get_url:
url: https://artifacts.elastic.co/downloads/kibana/kibana-7.8.1-amd64.deb
dest: /tmp
- name: Install Kibana Deb Package
become: yes
apt:
deb: /tmp/kibana-7.8.1-amd64.deb
- name: Update Kibana Config (IP Address)
become: yes
lineinfile:
destfile: /etc/kibana/kibana.yml
regexp: 'server.host'
line: 'server.host: "0.0.0.0"'
- name: Update Kibana Config (Kibana URL)
become: yes
lineinfile:
destfile: /etc/kibana/kibana.yml
regexp: 'elasticsearch.hosts'
line: 'elasticsearch.hosts: ["http://192.168.5.71:9200"]'
- name: Start Kibana Service
become: yes
service:
name: kibana
state: started
- hosts: elkservers
gather_facts: no
tasks:
- name: Download Logstash Deb Package
get_url:
url: https://artifacts.elastic.co/downloads/logstash/logstash-7.8.1.deb
dest: /tmp
- name: Install Logstash Deb Package
become: yes
apt:
deb: /tmp/logstash-7.8.1.deb
- name: Create Logstash Pipeline File
become: yes
file:
path: /etc/logstash/conf.d/main.conf
state: touch
- name: Add Logstash Pipeline Configuration
become: yes
blockinfile:
path: /etc/logstash/conf.d/main.conf
marker: ""
block: |
input {
beats {
port => 5044
}
}
output {
elasticsearch { hosts => ["192.168.5.71:9200"]
}
}
- name: Download Filebeat Package
get_url:
url: https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.8.1-amd64.deb
dest: /tmp
- name: Install FileBeat Deb Package
become: yes
apt:
deb: /tmp/filebeat-7.8.1-amd64.deb
- name: Remove FileBeat YAML File
become: yes
file:
path: /etc/filebeat/filebeat.yml
state: absent
- name: Create New FileBeat YAML File
become: yes
file:
path: /etc/filebeat/filebeat.yml
state: touch
- name: Add FileBeat YAML Configuration
become: yes
blockinfile:
path: /etc/filebeat/filebeat.yml
marker: ""
block: |
filebeat.inputs:
- type: log
paths:
- /var/log/*.log
output.logstash:
hosts: ["localhost:5044"]
- name: Start Logstash Service
become: yes
service:
name: logstash
state: started
- name: Start FileBeat Service
become: yes
service:
name: filebeat
state: started