Skip to content

Commit

Permalink
add optional repo_priority parameter (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
kpankonen authored and pcfens committed Jun 2, 2017
1 parent 00e0b72 commit 758656e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Installs and configures filebeat.
- `manage_repo`: [Boolean] Whether or not the upstream (elastic) repo should be configured or not (default: true)
- `service_ensure`: [String] The ensure parameter on the filebeat service (default: running)
- `service_enable`: [String] The enable parameter on the filebeat service (default: true)
- `param repo_priority`: [Integer] Repository priority. yum and apt supported (default: undef)
- `service_provider`: [String] The provider parameter on the filebeat service (default: on RedHat based systems use redhat, otherwise undefined)
- `spool_size`: [Integer] How large the spool should grow before being flushed to the network (default: 2048)
- `idle_timeout`: [String] How often the spooler should be flushed even if spool size isn't reached (default: 5s)
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# @param manage_repo [Boolean] Whether or not the upstream (elastic) repo should be configured or not (default: true)
# @param service_ensure [String] The ensure parameter on the filebeat service (default: running)
# @param service_enable [String] The enable parameter on the filebeat service (default: true)
# @param repo_priority [Integer] Repository priority. yum and apt supported (default: undef)
# @param spool_size [Integer] How large the spool should grow before being flushed to the network (default: 2048)
# @param idle_timeout [String] How often the spooler should be flushed even if spool size isn't reached (default: 5s)
# @param publish_async [Boolean] If set to true filebeat will publish while preparing the next batch of lines to send (defualt: false)
Expand Down Expand Up @@ -53,6 +54,7 @@
$service_ensure = $filebeat::params::service_ensure,
$service_enable = $filebeat::params::service_enable,
$service_provider = $filebeat::params::service_provider,
$repo_priority = undef,
$spool_size = $filebeat::params::spool_size,
$idle_timeout = $filebeat::params::idle_timeout,
$publish_async = $filebeat::params::publish_async,
Expand Down Expand Up @@ -93,6 +95,10 @@

validate_bool($manage_repo, $processors_merge, $prospectors_merge)

if $repo_priority != undef {
validate_integer($repo_priority)
}

if $major_version == undef and getvar('::filebeat_version') == undef {
$real_version = '5'
} elsif $major_version == undef and versioncmp($::filebeat_version, '5.0.0') >= 0 {
Expand Down
2 changes: 2 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
location => $debian_repo_url,
release => 'stable',
repos => 'main',
pin => $::filebeat::repo_priority,
key => {
id => '46095ACC8548582C1A2699A9D27D666CD88E42B4',
source => 'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
Expand All @@ -36,6 +37,7 @@
baseurl => $yum_repo_url,
gpgcheck => 1,
gpgkey => 'https://artifacts.elastic.co/GPG-KEY-elasticsearch',
priority => $::filebeat::repo_priority,
enabled => 1,
}
}
Expand Down
68 changes: 68 additions & 0 deletions spec/classes/filebeat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,74 @@
end
end

context 'when seting repository priority' do
let :facts do
{
kernel: 'Linux',
osfamily: 'Debian',
lsbdistid: 'Ubuntu',
lsbdistrelease: '16.04',
rubyversion: '1.9.3',
puppetversion: Puppet.version,
filebeat_version: '5.2.2'
}
end

let :params do
{
repo_priority: 10
}
end

context 'defaults' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_package('filebeat') }
it { is_expected.to contain_class('filebeat::params') }
it { is_expected.to contain_anchor('filebeat::begin') }
it { is_expected.to contain_anchor('filebeat::end') }
it { is_expected.to contain_class('filebeat::install') }
it { is_expected.to contain_class('filebeat::config') }
it { is_expected.to contain_anchor('filebeat::install::begin') }
it { is_expected.to contain_anchor('filebeat::install::end') }
it { is_expected.to contain_class('filebeat::install::linux') }
it { is_expected.to contain_class('filebeat::repo') }
it { is_expected.to contain_class('filebeat::service') }
it { is_expected.not_to contain_class('filebeat::install::windows') }
it do
is_expected.to contain_apt__source('beats').with(
pin => 10
)
end
end

describe 'on a RHEL system' do
let :facts do
{
kernel: 'Linux',
osfamily: 'RedHat',
rubyversion: '1.8.7',
puppetversion: Puppet.version,
filebeat_version: '5.2.2'
}
end

it { is_expected.to compile.with_all_deps }
it { is_expected.to contain_class('filebeat::params') }
it { is_expected.to contain_anchor('filebeat::begin') }
it { is_expected.to contain_anchor('filebeat::end') }
it { is_expected.to contain_class('filebeat::install') }
it { is_expected.to contain_class('filebeat::config') }
it { is_expected.to contain_anchor('filebeat::install::begin') }
it { is_expected.to contain_anchor('filebeat::install::end') }

it do
is_expected.to contain_yumrepo('beats').with(
priority => 10
)
end
end
end

context 'when uninstalling filebeat' do
let :facts do
{
Expand Down

0 comments on commit 758656e

Please sign in to comment.