Skip to content

Commit

Permalink
Merge pull request #12 from corey-hammerton/path-params
Browse files Browse the repository at this point in the history
Removing all $path_* parameters.
  • Loading branch information
corey-hammerton authored Dec 28, 2017
2 parents a2b0c67 + 56b724a commit 380b16a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 42 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ Installs and configures packetbeat.
to the node's package manager. (default: true)
- `package_ensure`: [String] The desired state of the Package resources. Only
applicable if `ensure` is 'present'. (default: 'present')
- `path_conf`: [Stdlib::Absolutepath] The base path for all packetbeat
configurations. (default: /etc/packetbeat)
- `path_data`: [Stdlib::Absolutepath] The base path to where packetbeat stores
its data. (default: /var/lib/packetbeat)
- `path_home`: [Stdlib::Absolutepath] The base path for the packetbeat installation,
where the packetbeat binary is stored. (default: /usr/share/packetbeat)
- `path_logs`: [Stdlib::Absolutepath] The base path for packetbeat's log files.
(default: /var/log/packetbeat)
- `processors`: [Array[Hash]] Add processors to the configuration to run on data
before sending to the output. (default: undef)
- `queue`: [Hash] Configure the internal queue in packetbeat before being consumed
Expand All @@ -231,7 +223,7 @@ Installs and configures packetbeat.

#### Class: `packetbeat::config`

Manages packetbeats main configuration file under `path_conf`
Manages packetbeats main configuration file.

#### Class: `packetbeat::install`

Expand Down
19 changes: 3 additions & 16 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@
class packetbeat::config inherits packetbeat {
$validate_cmd = $packetbeat::disable_config_test ? {
true => undef,
default => "${packetbeat::path_home}/bin/packetbeat -N -configtest -c %",
default => '/usr/share/packetbeat/bin/packetbeat -N -configtest -c %',
}

if $packetbeat::major_version == '5' {
$packetbeat_config = delete_undef_values({
'name' => $packetbeat::beat_name,
'fields' => $packetbeat::fields,
'fields_under_root' => $packetbeat::fields_under_root,
'logging' => $packetbeat::logging,
'path' => {
'conf' => $packetbeat::path_conf,
'data' => $packetbeat::path_data,
'home' => $packetbeat::path_home,
'logs' => $packetbeat::path_logs,
},
'tags' => $packetbeat::tags,
'processors' => $packetbeat::processors,
'packetbeat' => {
Expand All @@ -47,12 +40,6 @@
'fields' => $packetbeat::fields,
'fields_under_root' => $packetbeat::fields_under_root,
'logging' => $packetbeat::logging,
'path' => {
'conf' => $packetbeat::path_conf,
'data' => $packetbeat::path_data,
'home' => $packetbeat::path_home,
'logs' => $packetbeat::path_logs,
},
'tags' => $packetbeat::tags,
'processors' => $packetbeat::processors,
'packetbeat' => {
Expand Down Expand Up @@ -89,11 +76,11 @@

file{'packetbeat.yml':
ensure => $packetbeat::ensure,
path => "${packetbeat::path_conf}/packetbeat.yml",
path => '/etc/packetbeat/packetbeat.yml',
owner => 'root',
group => 'root',
mode => $packetbeat::config_file_mode,
content => inline_template("### Packetbeat configuration managed by Puppet ###\n\n<%= @packetbeat_config.to_yaml() %>"),
content => inline_template('<%= @packetbeat_config.to_yaml() %>'),
validate_cmd => $validate_cmd,
}
}
17 changes: 0 additions & 17 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,6 @@
# * `package_ensure`
# [String] The state the packetbeat package should be in. (default: present)
#
# * `path_conf`
# [Absolute Path] The location of the configuration files. This setting
# also controls the path to `packetbeat.yml`.
#
# * `path_data`
# [Absolute Path] The location of the persistent data files.
#
# * `path_home`
# [Absolute Path] The home of the Packetbeat configuration.
#
# * `path_logs`
# [Absolute Path] The location of the logs created by Packetbeat.
#
# * `processors`
# Optional[Array[Hash]] Configure processors to perform filtering,
# enhancing or additional decoding of data before being sent to the
Expand Down Expand Up @@ -200,10 +187,6 @@
Enum['5', '6'] $major_version = '5',
Boolean $manage_repo = true,
String $package_ensure = 'present',
Stdlib::Absolutepath $path_conf = '/etc/packetbeat',
Stdlib::Absolutepath $path_data = '/var/lib/packetbeat',
Stdlib::Absolutepath $path_home = '/usr/share/packetbeat',
Stdlib::Absolutepath $path_logs = '/var/log/packetbeat',
Optional[Array[Hash]] $processors = undef,
Hash $queue = {
'mem' => {
Expand Down
24 changes: 24 additions & 0 deletions spec/classes/packetbeat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,30 @@
it { is_expected.to contain_class('packetbeat::service') }
end

context 'with path_conf param' do
let(:params) { { 'path_conf' => '/etc/packetbeat' } }

it { is_expected.not_to compile }
end

context 'with path_data param' do
let(:params) { { 'path_data' => '/var/lib/packetbeat' } }

it { is_expected.not_to compile }
end

context 'with path_home param' do
let(:params) { { 'path_home' => '/usr/share/packetbeat' } }

it { is_expected.not_to compile }
end

context 'with path_logs param' do
let(:params) { { 'path_logs' => '/var/lgs/packetbeat' } }

it { is_expected.not_to compile }
end

context 'with sniff_type = pf_ring' do
let :params do
{
Expand Down

0 comments on commit 380b16a

Please sign in to comment.