From 105babcbb77375a20ee46c3d4478116e4ad95b2f Mon Sep 17 00:00:00 2001 From: smasa90 Date: Thu, 11 Jul 2019 13:57:13 +1100 Subject: [PATCH 1/3] feat(beats): add management of filebeat and journalbeats --- README.md | 18 ++++++++++++++++-- data/common.yaml | 2 ++ spec/classes/beats_spec.rb | 12 ++++++++++++ spec/type_aliases/managed_beats_spec.rb | 2 ++ types/managed_beats.pp | 11 ++++++++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 749b1ce..8a3d363 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,14 @@ Include the `beats` class and pass a list of individual Beats to manage with `ma ```puppet class { 'beats': - $managed_beats => ['metricbeat','auditbeat','heartbeat-elastic','packetbeat'] + $managed_beats => [ + 'auditbeat', + 'filebeat', + 'heartbeat-elastic', + 'journalbeat', + 'metricbeat', + 'packetbeat', + ] } ``` @@ -57,7 +64,14 @@ There is very few parameters you should need to customise. The most useful woul ```puppet class { 'beats': - managed_beats => ['metricbeat','auditbeat','heartbeat-elastic','packetbeat'], + managed_beats => [ + 'auditbeat', + 'filebeat', + 'heartbeat-elastic', + 'journalbeat', + 'metricbeat', + 'packetbeat', + ], config_root => '/opt/beats' } ``` diff --git a/data/common.yaml b/data/common.yaml index 4da94b8..7660cdc 100644 --- a/data/common.yaml +++ b/data/common.yaml @@ -2,7 +2,9 @@ beats::config_root: '/etc' beats::manage_repo: true beats::managed_beats: - 'auditbeat' + - 'filebeat' - 'heartbeat-elastic' + - 'journalbeat' - 'metricbeat' - 'packetbeat' beats::package_ensure: present diff --git a/spec/classes/beats_spec.rb b/spec/classes/beats_spec.rb index 45d43dd..e27133d 100644 --- a/spec/classes/beats_spec.rb +++ b/spec/classes/beats_spec.rb @@ -19,7 +19,9 @@ end describe 'beats::install' do it { is_expected.to contain_package('auditbeat') } + it { is_expected.to contain_package('filebeat') } it { is_expected.to contain_package('heartbeat-elastic') } + it { is_expected.to contain_package('journalbeat') } it { is_expected.to contain_package('metricbeat') } it { is_expected.to contain_package('packetbeat') } end @@ -35,7 +37,9 @@ describe 'beats::service' do it { is_expected.to contain_file('auditbeat_config') } it { is_expected.to contain_service('auditbeat').that_subscribes_to('File[auditbeat_config]') } + it { is_expected.to contain_service('filebeat') } it { is_expected.to contain_service('heartbeat-elastic') } + it { is_expected.to contain_service('journalbeat') } it { is_expected.to contain_service('metricbeat') } it { is_expected.to contain_service('packetbeat') } end @@ -53,7 +57,9 @@ end describe 'beats::install' do it { is_expected.not_to contain_package('auditbeat') } + it { is_expected.not_to contain_package('filebeat') } it { is_expected.not_to contain_package('heartbeat-elastic') } + it { is_expected.not_to contain_package('journalbeat') } it { is_expected.not_to contain_package('metricbeat') } it { is_expected.not_to contain_package('packetbeat') } end @@ -85,7 +91,9 @@ end describe 'beats::service' do it { is_expected.not_to contain_service('auditbeat') } + it { is_expected.not_to contain_service('filebeat') } it { is_expected.not_to contain_service('heartbeat-elastic') } + it { is_expected.not_to contain_service('journalbeat') } it { is_expected.not_to contain_service('metricbeat') } it { is_expected.not_to contain_service('packetbeat') } end @@ -104,7 +112,9 @@ describe 'beats::install' do it { is_expected.to contain_package('metricbeat') } it { is_expected.not_to contain_package('auditbeat') } + it { is_expected.not_to contain_package('filebeat') } it { is_expected.not_to contain_package('heartbeat-elastic') } + it { is_expected.not_to contain_package('journalbeat') } it { is_expected.not_to contain_package('packetbeat') } end describe 'beats::config' do @@ -114,7 +124,9 @@ describe 'beats::service' do it { is_expected.to contain_service('metricbeat') } it { is_expected.not_to contain_service('auditbeat') } + it { is_expected.not_to contain_service('filebeat') } it { is_expected.not_to contain_service('heartbeat-elastic') } + it { is_expected.not_to contain_service('journalbeat') } it { is_expected.not_to contain_service('packetbeat') } end end diff --git a/spec/type_aliases/managed_beats_spec.rb b/spec/type_aliases/managed_beats_spec.rb index 2030787..130d4fd 100644 --- a/spec/type_aliases/managed_beats_spec.rb +++ b/spec/type_aliases/managed_beats_spec.rb @@ -4,7 +4,9 @@ describe 'with valid inputs' do [ ['auditbeat'], + ['filebeat'], ['heartbeat-elastic'], + ['journalbeat'], ['metricbeat'], ['packetbeat'], %w[auditbeat heartbeat-elastic], diff --git a/types/managed_beats.pp b/types/managed_beats.pp index a06e6c3..0577238 100644 --- a/types/managed_beats.pp +++ b/types/managed_beats.pp @@ -1 +1,10 @@ -type Beats::Managed_beats = Array[Enum['auditbeat', 'heartbeat-elastic', 'metricbeat', 'packetbeat']] +type Beats::Managed_beats = Array[ + Enum[ + 'auditbeat', + 'filebeat', + 'heartbeat-elastic', + 'journalbeat', + 'metricbeat', + 'packetbeat', + ] +] From 9dee6dfdf34370370e3de7e57dca45442fa7bff9 Mon Sep 17 00:00:00 2001 From: smasa90 Date: Thu, 11 Jul 2019 15:01:58 +1100 Subject: [PATCH 2/3] fix(spec): stdlib >= 4.0.0 is dependant of augeas Require puppet >= 4.10.0 See commit https://github.com/puppetlabs/puppetlabs-stdlib/commit/35f9a01879858fcbd0c93c1fd90ff71365a27d9b --- .travis.yml | 2 +- spec/acceptance/nodesets/centos-7-x64.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 95a1c6d..5202d3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ jobs: - stage: intake env: - TASK=test - - PUPPET_VERSION='~> 4.5.0' + - PUPPET_VERSION='~> 4.10.0' - env: - TASK=test - env: diff --git a/spec/acceptance/nodesets/centos-7-x64.yml b/spec/acceptance/nodesets/centos-7-x64.yml index 78c2144..660abc2 100644 --- a/spec/acceptance/nodesets/centos-7-x64.yml +++ b/spec/acceptance/nodesets/centos-7-x64.yml @@ -14,7 +14,7 @@ HOSTS: docker_pid_mode: 'host' docker_preserve_image: true docker_image_commands: - - yum install -y wget which cronie iproute + - yum install -y wget which cronie iproute augeas-devel - mkdir -p /etc/selinux/targeted/contexts/ - echo '' > /etc/selinux/targeted/contexts/dbus_contexts - rm /lib/systemd/system/systemd*udev* From 6348793f8dedb587ab3e6cb831d01d0fc9294b04 Mon Sep 17 00:00:00 2001 From: smasa90 Date: Tue, 30 Jul 2019 15:25:30 +1100 Subject: [PATCH 3/3] fix(config): misuse of File default --- manifests/config.pp | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index e23bca1..e86415a 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -3,7 +3,13 @@ class beats::config { $beats::managed_beats.each |String $beat| { # Generate beat config name - $beat_config = "${beats::config_root}/${beat}/${beat}.yml" + if ( $beat == 'heartbeat-elastic' ) { + $ef_beat = 'heartbeat' + } + else { $ef_beat = $beat } + + + $beat_config = "${beats::config_root}/${ef_beat}/${ef_beat}.yml" # Get beat settings $settings = lookup("beats::${beat}::settings", Data, 'deep', undef) @@ -19,24 +25,36 @@ } } - # Set File defaults - File { - ensure => file, - path => $beat_config, - owner => 0, - group => 0, - mode => '0600', - notify => $_notify, - } + # # Set File defaults + # File { + # ensure => file, + # path => $beat_config, + # owner => 0, + # group => 0, + # mode => '0600', + # notify => $_notify, + # } case type($settings) { String: { file { "${beat}_config": + ensure => 'file', + path => $beat_config, + owner => 0, + group => 0, + mode => '0600', + notify => $_notify, source => $settings, } } default: { file { "${beat}_config": + ensure => 'file', + path => $beat_config, + owner => 0, + group => 0, + mode => '0600', + notify => $_notify, content => epp('beats/beat.yml.epp', { beat => $beat, settings => $settings }), } }