Skip to content

Commit

Permalink
install: respect manage_repo flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjl committed Mar 11, 2017
1 parent 815e387 commit ee7c394
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 56 deletions.
114 changes: 58 additions & 56 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,67 +9,69 @@
default => 'present',
}

if $::kibana::repo_version =~ /^4[.]/ {
$_repo_baseurl = "https://packages.elastic.co/kibana/${::kibana::repo_version}"
$_repo_path = $::osfamily ? {
'Debian' => 'debian',
/(RedHat|Amazon)/ => 'centos'
}
} else {
$_repo_baseurl = "https://artifacts.elastic.co/packages/${::kibana::repo_version}"
$_repo_path = $::osfamily ? {
'Debian' => 'apt',
/(RedHat|Amazon)/ => 'yum'
if $::kibana::manage_repo {
if $::kibana::repo_version =~ /^4[.]/ {
$_repo_baseurl = "https://packages.elastic.co/kibana/${::kibana::repo_version}"
$_repo_path = $::osfamily ? {
'Debian' => 'debian',
/(RedHat|Amazon)/ => 'centos'
}
} else {
$_repo_baseurl = "https://artifacts.elastic.co/packages/${::kibana::repo_version}"
$_repo_path = $::osfamily ? {
'Debian' => 'apt',
/(RedHat|Amazon)/ => 'yum'
}
}
}

case $::osfamily {
'Debian': {
include ::apt
package { 'apt-transport-https' :
before => Class['apt::update'],
}
Class['apt::update'] -> Package['kibana']
case $::osfamily {
'Debian': {
include ::apt
package { 'apt-transport-https' :
before => Class['apt::update'],
}
Class['apt::update'] -> Package['kibana']

apt::source { 'kibana':
ensure => $_ensure,
location => "${_repo_baseurl}/${_repo_path}",
release => 'stable',
repos => 'main',
key => {
'id' => $::kibana::repo_key_id,
'source' => $::kibana::repo_key_source,
},
include => {
'src' => false,
'deb' => true,
},
pin => $::kibana::repo_priority,
before => Package['kibana'],
apt::source { 'kibana':
ensure => $_ensure,
location => "${_repo_baseurl}/${_repo_path}",
release => 'stable',
repos => 'main',
key => {
'id' => $::kibana::repo_key_id,
'source' => $::kibana::repo_key_source,
},
include => {
'src' => false,
'deb' => true,
},
pin => $::kibana::repo_priority,
before => Package['kibana'],
}
}
}
'RedHat', 'Amazon': {
yumrepo { 'kibana':
ensure => $_ensure,
descr => "Elastic ${::kibana::repo_version} repository",
baseurl => "${_repo_baseurl}/${_repo_path}",
gpgcheck => 1,
gpgkey => $::kibana::repo_key_source,
enabled => 1,
proxy => $::kibana::repo_proxy,
priority => $::kibana::repo_priority,
before => Package['kibana'],
} ~>
exec { 'kibana_yumrepo_yum_clean':
command => 'yum clean metadata expire-cache --disablerepo="*" --enablerepo="kibana"',
path => [ '/bin', '/usr/bin' ],
refreshonly => true,
returns => [0, 1],
before => Package['kibana'],
'RedHat', 'Amazon': {
yumrepo { 'kibana':
ensure => $_ensure,
descr => "Elastic ${::kibana::repo_version} repository",
baseurl => "${_repo_baseurl}/${_repo_path}",
gpgcheck => 1,
gpgkey => $::kibana::repo_key_source,
enabled => 1,
proxy => $::kibana::repo_proxy,
priority => $::kibana::repo_priority,
before => Package['kibana'],
} ~>
exec { 'kibana_yumrepo_yum_clean':
command => 'yum clean metadata expire-cache --disablerepo="*" --enablerepo="kibana"',
path => [ '/bin', '/usr/bin' ],
refreshonly => true,
returns => [0, 1],
before => Package['kibana'],
}
}
default: {
fail("unsupported operating system family ${::osfamily}")
}
}
default: {
fail("unsupported operating system family ${::osfamily}")
}
}

Expand Down
15 changes: 15 additions & 0 deletions spec/classes/kibana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,21 @@
end
end
end

describe 'manage_repo' do
let(:params) { { :manage_repo => false } }
case facts[:osfamily]
when 'Debian'
it { is_expected.not_to contain_class('apt') }
it { is_expected.not_to contain_package('apt-transport-https') }
it { is_expected.not_to contain_apt__source('kibana') }
when 'RedHat'
it { is_expected.not_to contain_yumrepo('kibana') }
it { is_expected.not_to contain_exec('kibana_yumrepo_yum_clean') }
else
pending "no tests for #{facts[:osfamily]}"
end
end
end
end
end
Expand Down

0 comments on commit ee7c394

Please sign in to comment.