-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yml
42 lines (33 loc) · 1.29 KB
/
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
---
- hosts: all
vars:
packagename: topbeat_1.0.0-rc1_amd64.deb
es_host: 127.0.0.1
es_port: 9200
period: 30
start: true
autostart: true
install_template: false
tasks:
- name: add elastic repo key
apt_key: url=https://packages.elasticsearch.org/GPG-KEY-elasticsearch state=present
- name: add beats repository
apt_repository: repo='deb https://packages.elastic.co/beats/apt stable main' state=present
- name: install topbeat
apt: pkg=topbeat state=present update_cache=yes
- name: configure topbeat interval
lineinfile: 'dest=/etc/topbeat/topbeat.yml "regexp=^ period:.*" line=" period: {{ period }}"'
- name: configure topbeat elasticsearch
lineinfile: 'dest=/etc/topbeat/topbeat.yml regexp="^ hosts:.*" line=" hosts: [\"{{ es_host }}:{{ es_port }}\"]"'
- name: ensure curl is installed
apt: package=curl state=present update_cache=yes
when: install_template
- name: insert template into elasticsearch
shell: 'curl -s {{ es_host }}:{{ es_port }}/_template/topbeat -d @/etc/topbeat/topbeat.template.json '
when: install_template
- name: start topbeat service
service: name=topbeat state=started
when: start
- name: add topbeat to autostart
shell: update-rc.d topbeat defaults 95 10
when: autostart