-
Notifications
You must be signed in to change notification settings - Fork 1
/
CentOS7x_Install-Metricbeat-playbook.yml
76 lines (60 loc) · 2.57 KB
/
CentOS7x_Install-Metricbeat-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
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
---
################################################################################
# description: Installs Metricbeat on CentOS7x
# usage: ansible-playbook CentOS7x_Install-Metricbeat-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere LogstashIP=IPAddressHere'
# author: Ernest G. Wilson II <ErnestGWilsonII@gmail.com> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Install Metricbeat on CentOS7x
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Install or configure repository used on the OS by yum
# REF: https://docs.ansible.com/ansible/yum_repository_module.html
##################################################################
# /etc/yum.repos.d/elasticsearch.repo
- name: Install repository Elasticsearch
yum_repository:
name: elasticsearch
description: Elasticsearch repository
file: elasticsearch
baseurl: https://artifacts.elastic.co/packages/5.x/yum
enabled: yes
gpgcheck: yes
gpgkey: https://packages.elastic.co/GPG-KEY-elasticsearch
# Install yum packages
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
- name: Install metricbeat
yum:
name=metricbeat
state=latest
# Use the template module to populate files with data
# REF: http://docs.ansible.com/ansible/template_module.html
###########################################################
# /etc/metricbeat/metricbeat.yml
- name: Fill in the variables and copy templates/Metricbeat/metricbeat.yml.j2 to remote /etc/metricbeat/metricbeat.yml
template:
src=templates/Metricbeat/metricbeat.yml.j2
dest=/etc/metricbeat/metricbeat.yml
owner=root
group=root
mode=0644
# Enable and start service
# REF: http://docs.ansible.com/ansible/service_module.html
##########################################################
- name: Enable and start the Metricbeat service
service:
name=metricbeat
enabled=yes
state=restarted
# Note: Command line verification:
# systemctl status metricbeat
# systemctl status metricbeat.service -l
# service metricbeat status
# cat /var/log/messages | grep metricbeat
# metricbeat.sh -c /etc/metricbeat/metricbeat.yml -configtest