Skip to content

Commit

Permalink
allow selection unstable, nightly, etc repo type (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmckinst authored and yankcrime committed Jul 12, 2016
1 parent cf57e03 commit dd4235f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ travis.log
.vagrant
spec/fixtures/*
junit
.bundle/
vendor/
5 changes: 5 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
# [*manage_repo*]
# Boolean. Whether or not to manage InfluxData's repo.
#
# [*repo_type*]
# String. Which repo (stable, unstable, nightly) to use
#
class telegraf (
$ensure = $telegraf::params::ensure,
$config_file = $telegraf::params::config_file,
Expand All @@ -75,6 +78,7 @@
$global_tags = $telegraf::params::global_tags,
$manage_service = $telegraf::params::manage_service,
$manage_repo = $telegraf::params::manage_repo,
$repo_type = $telegraf::params::repo_type,
) inherits ::telegraf::params
{

Expand All @@ -95,6 +99,7 @@
validate_hash($global_tags)
validate_bool($manage_service)
validate_bool($manage_repo)
validate_string($repo_type)

# currently the only way how to obtain merged hashes
# from multiple files (`:merge_behavior: deeper` needs to be
Expand Down
4 changes: 2 additions & 2 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
comment => 'Mirror for InfluxData packages',
location => "https://repos.influxdata.com/${_operatingsystem}",
release => $::distcodename,
repos => 'stable',
repos => $::telegraf::repo_type,
key => {
'id' => '05CE15085FC09D18E99EFB22684A14CF2582E0C5',
'source' => 'https://repos.influxdata.com/influxdb.key',
Expand All @@ -28,7 +28,7 @@
yumrepo { 'influxdata':
descr => 'influxdata',
enabled => 1,
baseurl => "https://repos.influxdata.com/rhel/${::operatingsystemmajrelease}/${::architecture}/stable",
baseurl => "https://repos.influxdata.com/rhel/${::operatingsystemmajrelease}/${::architecture}/${::telegraf::repo_type}",
gpgkey => 'https://repos.influxdata.com/influxdb.key',
gpgcheck => true,
}
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$global_tags = {}
$manage_service = true
$manage_repo = true
$repo_type = 'stable'

$outputs = {
'influxdb' => {
Expand Down
27 changes: 21 additions & 6 deletions spec/classes/telegraf_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
[6,7].each do |releasenum|
context "RedHat #{releasenum} release specifics" do
let(:facts) {{
:osfamily => 'RedHat',
:kernel => 'Linux',
:operatingsystem => osfamily,
:operatingsystemrelease => releasenum,
:role => 'telegraf'
:osfamily => 'RedHat',
:architecture => 'x86_64',
:kernel => 'Linux',
:operatingsystem => osfamily,
:operatingsystemrelease => releasenum,
:operatingsystemmajrelease => releasenum,
:role => 'telegraf'
}}
it { should compile.with_all_deps }
it { should contain_class('telegraf::config') }
Expand Down Expand Up @@ -77,7 +79,20 @@
it { should contain_file('/etc/telegraf/telegraf.conf') }
it { should contain_package('telegraf') }
it { should contain_service('telegraf') }
it { should contain_yumrepo('influxdata') }
it { should contain_yumrepo('influxdata')
.with(
:baseurl => "https://repos.influxdata.com/rhel/#{facts[:operatingsystemmajrelease]}/#{facts[:architecture]}/stable",
)
}

describe 'allow custom repo_type' do
let(:params) { {:repo_type => 'unstable' } }
it { should contain_yumrepo('influxdata')
.with(
:baseurl => "https://repos.influxdata.com/rhel/#{facts[:operatingsystemmajrelease]}/#{facts[:architecture]}/unstable",
)
}
end
end
end
end
Expand Down

0 comments on commit dd4235f

Please sign in to comment.