Skip to content

Commit b11646b

Browse files
committed
Added role tasks, handlers, vars and defaults. Properly updated metadata and README.md.
1 parent d1b62f6 commit b11646b

File tree

10 files changed

+148
-51
lines changed

10 files changed

+148
-51
lines changed

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
restlesset.filebeat
1+
Restless-ET.filebeat
22
=========
33

4-
An Ansible role for Elastic's Filebeat log shipper.
4+
An Ansible role for Logstash's Filebeat log shipper.
55

66
Requirements
77
------------
88

9-
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
9+
Nothing worth mentioning ...
1010

1111
Role Variables
1212
--------------
1313

14-
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
14+
- `filebeat_version` - The filebeat version to install. Defaults to: `1.0.1`
15+
- `filebeat_prospectors` - List of prospectors to fetch data.
16+
- `filebeat_logstash_enabled` - If Logstash output if enabled or not. Defaults to: `true`
17+
- `filebeat_logstash_index` - The index root name to write evetns to. Defaults to: `filebeat`
18+
- `filebeat_logstash_hosts` - The list of downstream Logstash servers. Defaults to: `["localhost:5044"]`
19+
- `filebeat_logstash_tls_insecure` - If the client skips verification of server certificates and host names. Defaults to: `false`
20+
- `filebeat_logstash_tls_certificate` - The path to your SSL client certificate.
21+
- `filebeat_logstash_tls_certificate_key` - The path to your SSL client certificate key.
22+
- `filebeat_logstash_tls_certificate_authorities` - The list of paths to root certificates for server verifications.
23+
- `filebeat_logstash_tls_timeout` - Network timeout in seconds. Defaults to: `15`
24+
1525

1626
Dependencies
1727
------------
1828

19-
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
29+
No dependecies. :-)
2030

2131
Example Playbook
2232
----------------
@@ -25,14 +35,20 @@ Including an example of how to use your role (for instance, with variables passe
2535

2636
- hosts: servers
2737
roles:
28-
- { role: username.rolename, x: 42 }
38+
- { role: Restless-ET.filebeat,
39+
filebeat_prospectors:
40+
- {
41+
document_type: syslog,
42+
paths: ['/var/log/syslog']
43+
}
44+
}
2945

3046
License
3147
-------
3248

33-
BSD
49+
MIT
3450

3551
Author Information
3652
------------------
3753

38-
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
54+
Artur Melo

defaults/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
---
2-
# defaults file for restlesset.filebeat
2+
filebeat_version: 1.0.1
3+
4+
filebeat_prospectors: [] # List of prospectors to fetch data.
5+
6+
filebeat_logstash_enabled: true
7+
filebeat_logstash_index: filebeat
8+
filebeat_logstash_hosts: ["localhost:5044"] # The list of downstream Logstash servers.
9+
filebeat_logstash_tls_insecure: false
10+
filebeat_logstash_tls_certificate: ~ # The path to your SSL client certificate.
11+
filebeat_logstash_tls_certificate_key: ~ # The path to your SSL client certificate key.
12+
filebeat_logstash_tls_certificate_authorities: [] # The paths to root certificates for server verifications.
13+
filebeat_logstash_tls_timeout: 15 # Network timeout in seconds.

handlers/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
---
2-
# handlers file for restlesset.filebeat
2+
- name: restart filebeat
3+
service:
4+
name: filebeat
5+
state: restarted

meta/main.yml

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
galaxy_info:
22
author: Artur Melo
3-
description:
3+
description: Install and configure filebeat as a logs forwarder for logstash
44
company: be.ubi
55

6-
# If the issue tracker for your role is not on github, uncomment the
7-
# next line and provide a value
8-
# issue_tracker_url: http://example.com/issue/tracker
9-
10-
# Some suggested licenses:
11-
# - BSD (default)
12-
# - MIT
13-
# - GPLv2
14-
# - GPLv3
15-
# - Apache
16-
# - CC-BY
17-
license: license (GPLv2, CC-BY, etc)
6+
license: MIT
187

198
min_ansible_version: 1.2
209

@@ -30,11 +19,11 @@ galaxy_info:
3019
# Below are all platforms currently available. Just uncomment
3120
# the ones that apply to your role. If you don't see your
3221
# platform on this list, let us know and we'll get it added!
33-
#
34-
#platforms:
35-
#- name: EL
36-
# versions:
37-
# - all
22+
23+
platforms:
24+
- name: EL
25+
versions:
26+
- all
3827
# - 5
3928
# - 6
4029
# - 7
@@ -102,20 +91,21 @@ galaxy_info:
10291
# - 9.1
10392
# - 9.2
10493
# - 9.3
105-
#- name: Ubuntu
106-
# versions:
94+
- name: Ubuntu
95+
versions:
10796
# - all
10897
# - lucid
10998
# - maverick
11099
# - natty
111100
# - oneiric
112-
# - precise
101+
- precise
113102
# - quantal
114103
# - raring
115104
# - saucy
116-
# - trusty
105+
- trusty
117106
# - utopic
118-
# - vivid
107+
- vivid
108+
- wily
119109
#- name: SLES
120110
# versions:
121111
# - all
@@ -129,25 +119,19 @@ galaxy_info:
129119
# versions:
130120
# - all
131121
# - any
132-
#- name: Debian
133-
# versions:
122+
- name: Debian
123+
versions:
134124
# - all
135125
# - etch
136-
# - jessie
137126
# - lenny
138127
# - squeeze
139-
# - wheezy
128+
- wheezy
129+
- jessie
140130

141-
galaxy_tags: []
142-
# List tags for your role here, one per line. A tag is
143-
# a keyword that describes and categorizes the role.
144-
# Users find roles by searching for tags. Be sure to
145-
# remove the '[]' above if you add tags to this list.
146-
#
147-
# NOTE: A tag is limited to a single word comprised of
148-
# alphanumeric characters. Maximum 20 tags per role.
131+
galaxy_tags:
132+
- logs
133+
- logstash
134+
- monitoring
135+
- system
149136

150137
dependencies: []
151-
# List your role dependencies here, one per line.
152-
# Be sure to remove the '[]' above if you add dependencies
153-
# to this list.

tasks/debian.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
- name: 'Installing APT dependencies'
3+
apt:
4+
pkg: "{{ item }}"
5+
state: present
6+
with_items:
7+
- apt-transport-https
8+
9+
- name: Add elastic gpg key
10+
apt_key:
11+
url: "{{ filebeat_gpg_url }}"
12+
13+
- name: Add beats APT repository
14+
apt_repository:
15+
repo: "{{ filebeat_apt_repo }}"
16+
state: present
17+
update_cache: yes
18+
19+
- name: Install filebeat
20+
apt:
21+
name: filebeat={{ filebeat_version }}
22+
state: "{{ filebeat_package_state }}"
23+
notify:
24+
- restart filebeat

tasks/main.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
---
2-
# tasks file for restlesset.filebeat
2+
- include: debian.yml
3+
when: ansible_os_family == 'Debian'
4+
5+
- include: redhat.yml
6+
when: ansible_os_family == 'RedHat'
7+
8+
- name: Prepare filebeat config file
9+
template: src=filebeat-config.yml.j2 dest=/etc/filebeat/filebeat.yml
10+
notify:
11+
- restart filebeat
12+
13+
- name: Start and enable filebeat service
14+
service: name=filebeat enabled=yes state=started

tasks/redhat.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: Add rpm key for elastic.co
3+
rpm_key:
4+
key: "{{ filebeat_gpg_url }}"
5+
6+
- name: Create beats yum repo
7+
yumrepo:
8+
name: beats
9+
baseurl: "{{ filebeat_repo_url }}"
10+
enabled: yes
11+
gpgcheck: yes
12+
gpgkey: "{{ filebeat_gpg_url }}"
13+
14+
- name: Install filebeat
15+
yum:
16+
name: filebeat-{{ filebeat_version }}
17+
state: "{{ filebeat_package_state }}"
18+
notify:
19+
- restart filebeat

templates/filebeat-config.yml.j2

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
filebeat:
2+
prospectors:
3+
{{ filebeat_prospectors | to_yaml | indent(4) }}
4+
5+
output:
6+
logstash:
7+
enabled: {{ filebeat_logstash_enabled }}
8+
9+
index: {{ filebeat_logstash_index }}
10+
11+
hosts:
12+
{{ filebeat_logstash_hosts | to_nice_yaml | indent(6) }}
13+
14+
tls:
15+
insecure: {{ filebeat_logstash_tls_insecure }}
16+
17+
certificate: {{ filebeat_logstash_tls_certificate }}
18+
certificate_key: {{ filebeat_logstash_tls_certificate_key }}
19+
certificate_authorities:
20+
{{ filebeat_logstash_tls_certificate_authorities | to_nice_yaml | indent(8) }}
21+
22+
timeout: {{ filebeat_logstash_tls_timeout }}

tests/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
- hosts: localhost
33
remote_user: root
44
roles:
5-
- restlesset.filebeat
5+
- Restless-ET.filebeat

vars/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
---
2-
# vars file for restlesset.filebeat
2+
filebeat_apt_repo: "deb https://packages.elastic.co/beats/apt stable main"
3+
4+
filebeat_yum_repo_url: https://packages.elastic.co/beats/yum/el/$basearch
5+
6+
filebeat_gpg_url: https://packages.elastic.co/GPG-KEY-elasticsearch
7+
8+
filebeat_package_state: present

0 commit comments

Comments
 (0)