Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

[7.x] add support for beats 7.x #23

Merged
merged 5 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ suites:
- "."
run_list:
attributes:
- name: standard-6x
provisioner:
playbook: test/integration/standard-6x.yml
additional_copy_path:
- "."
run_list:
attributes:
- name: multi
provisioner:
playbook: test/integration/multi.yml
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Supported variables are as follows:

- **beat** (*MANDATORY*): Beat product. Supported values are: "filebeat", "metricbeat" & "packetbeat".
- **beat_conf** (*MANDATORY*): Beat Configuration. Should be defined as a map (see [Example Playbook](#example-playbook))
- **beats_version** (*Defaults to `6.2.4`*): Beats version. **Beats 7.x is not yet supported**.
- **beats_version** (*Defaults to `7.0.0`*): Beats version.
- **version_lock** (*Defaults to `false`*): Locks the installed version if set to true, thus preventing other processes from updating. This will not impact the roles ability to update the beat on subsequent runs (it unlocks and re-locks if required).
- **use_repository** (*Defaults to `true`*): Use elastic repo for yum or apt if true. If false, a custom custom_package_url must be provided.
- **start_service** (*Defaults to `true`*): service will be started if true, false otherwise.
Expand All @@ -47,7 +47,7 @@ Dependencies
------------

- Ansible version > 2.0
- Beats version >= 1.x
- Beats version >= 6.x

Example Playbook
----------------
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
# defaults file for beats

beats_version: 6.2.4
beats_version: 7.0.0
version_lock: false
use_repository: true
start_service: true
Expand Down
7 changes: 1 addition & 6 deletions tasks/beats-debian.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---

- name: "Debian - check that beats {{ beats_major_version }} version exists"
assert:
that:
"repo_urls[beats_major_version] is defined"

- name: Debian - Ensure apt-transport-https is installed
apt: name=apt-transport-https state=present cache_valid_time=86400
when: use_repository
Expand All @@ -16,7 +11,7 @@
when: use_repository

- name: Debian - add beats repository
apt_repository: repo="deb {{ repo_urls[beats_major_version] }} stable main" state=present
apt_repository: repo="deb {{ repo_url }} stable main" state=present
when: use_repository

- name: Debian - unhold {{beat}} version for install
Expand Down
5 changes: 0 additions & 5 deletions tasks/beats-redhat.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
---

- name: "RedHat - check that beats {{ beats_major_version }} version exists"
assert:
that:
"repo_urls[beats_major_version] is defined"

- name: Ensure libselinux-python on CentOS 6.x
yum: name=libselinux-python state=present update_cache=yes
when: ( ansible_distribution == "CentOS" ) and ( ansible_distribution_major_version == "6" )
Expand Down
2 changes: 1 addition & 1 deletion templates/beats.repo.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[beats]
name=Elastic Beats Repository
baseurl={{ repo_urls[beats_major_version] }}
baseurl={{ repo_url }}
enabled=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
gpgcheck=1
2 changes: 1 addition & 1 deletion test/integration/multi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: wrapper playbook for kitchen testing "beats"
hosts: localhost
roles:
- { role: "ansible-beats", beat: "filebeat", beat_conf: { "filebeat": {"prospectors":[{"paths":["/var/log/*.log"],"input_type":"log"}], "registry_file": "/var/lib/filebeat/registry"} } }
- { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"inputs":[{"paths":["/var/log/*.log"],"type":"log"}]} } }
- { role: "ansible-beats", beat: "metricbeat", beat_conf: { "metricbeat.modules": [{"module": "system", "metricsets": ["cpu", "filesystem", "network", "process"], "enabled": true, "period": "10s", "processes":[".*"], "cpu_ticks": false } ] } }
vars:
use_repository: "true"
8 changes: 8 additions & 0 deletions test/integration/standard-6x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
- name: wrapper playbook for kitchen testing "beats"
hosts: localhost
roles:
- { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"prospectors":[{"paths":["/var/log/*.log"],"input_type":"log"}], "registry_file": "/var/lib/filebeat/registry"} } }
vars:
beats_version: 6.7.1
use_repository: "true"
39 changes: 39 additions & 0 deletions test/integration/standard-6x/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'spec_helper'

describe 'Standard Tests' do

describe service('filebeat') do
it { should be_running }
end

describe package('filebeat') do
it { should be_installed }
end

describe file('/etc/filebeat/filebeat.yml') do
it { should be_file }
it { should be_owned_by 'root' }
end

describe file('/etc/filebeat/filebeat.yml') do
it { should contain 'filebeat:' }
it { should contain 'logging:' }
it { should contain 'output:' }
end

describe file('/etc/init.d/filebeat') do
it { should exist }
end

if os[:family] == 'redhat'
describe command('yum versionlock list | grep filebeat') do
its(:stdout) { should_not match /filebeat/ }
end
elsif ['debian', 'ubuntu'].include?(os[:family])
describe command('sudo apt-mark showhold | grep filebeat') do
its(:stdout) { should_not match /filebeat/ }
end
end

end

2 changes: 1 addition & 1 deletion test/integration/standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
- name: wrapper playbook for kitchen testing "beats"
hosts: localhost
roles:
- { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"prospectors":[{"paths":["/var/log/*.log"],"input_type":"log"}],"registry_file": "/var/lib/filebeat/registry"} } }
- { role: "ansible-beats", beat: "filebeat", beat_conf: {"filebeat": {"inputs":[{"paths":["/var/log/*.log"],"type":"log"}]} } }
vars:
use_repository: "true"
1 change: 1 addition & 0 deletions test/matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ OS:
- centos-7
TEST_TYPE:
- standard
- standard-6x
- multi
- config
5 changes: 1 addition & 4 deletions vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@

default_file: "/etc/default"
init_script: "/etc/init.d"
repo_urls:
"1.x": "http://packages.elastic.co/beats/apt"
"5.x": "https://artifacts.elastic.co/packages/5.x/apt"
"6.x": "https://artifacts.elastic.co/packages/6.x/apt"
repo_url: "https://artifacts.elastic.co/packages/{{ beats_major_version }}/apt"
5 changes: 1 addition & 4 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@

default_file: "/etc/sysconfig"
init_script: "/etc/init.d"
repo_urls:
"1.x": "https://packages.elastic.co/beats/yum/el/$basearch"
"5.x": "https://artifacts.elastic.co/packages/5.x/yum"
"6.x": "https://artifacts.elastic.co/packages/6.x/yum"
repo_url: "https://artifacts.elastic.co/packages/{{ beats_major_version }}/yum"