Skip to content

Commit

Permalink
Merge pull request #63 from alexharv074/manage_repo
Browse files Browse the repository at this point in the history
Add feature manage_repo
  • Loading branch information
Pierig Le Saux authored Jul 20, 2016
2 parents a33274d + e09afe2 commit bd11f06
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 14 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Version of Kibana4 that gets installed. Defaults to the latest version availabl

This parameter is deprecated. Only package installation from official `elastic.co` repositories is supported.

#### `manage_repo`

Whether or not to have the module also manage the Yum or Apt repos. Defaults to 'true'.

#### `package_repo_version`

Apt or yum repository version. Defaults to '4.5'.
Expand Down
9 changes: 3 additions & 6 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
#
class kibana4::config {

$_config_file = '/opt/kibana/config/kibana.yml'

if $kibana4::config {

file { 'kibana-config-file':
ensure => file,
path => $_config_file,
owner => $kibana4::kibana4_user,
group => $kibana4::kibana4_group,
path => '/opt/kibana/config/kibana.yml',
owner => 'kibana',
group => 'kibana',
mode => '0755',
content => template('kibana4/kibana.yml.erb'),
notify => Service['kibana4'],
}

}

}
19 changes: 14 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
# Version of Kibana4 that gets installed. Defaults to the latest version
# available in the `package_repo_version` that is selected.
#
# [*manage_repo*]
# Enable repo management by enabling the official repositories.
#
# [*package_repo_version*]
# apt or yum repository version. Only used if 'package_use_official_repo' is set to 'true'.
# defaults to '4.5'.
#
# [*package_repo_proxy*]
# A proxy to use for downloading packages.
# Defaults to 'undef'. You can change this if you are behind a proxy
#
# [*service_ensure*]
# Specifies the service state. Valid values are stopped (false) and running
# (true). Defaults to 'running'.
Expand All @@ -23,10 +30,6 @@
# [*service_name*]
# Name of the Kibana4 service. Defaults to 'kibana'.
#
# [*package_repo_proxy*]
# A proxy to use for downloading packages.
# Defaults to 'undef'. You can change this if you are behind a proxy
#
# [*babel_cache_path*]
# Kibana uses babel (https://www.npmjs.com/package/babel) which writes it's cache to this location
#
Expand All @@ -36,6 +39,7 @@
#
class kibana4 (
$version = $kibana4::params::version,
$manage_repo = $kibana4::params::manage_repo,
$package_repo_version = $kibana4::params::package_repo_version,
$package_repo_proxy = undef,
$service_ensure = $kibana4::params::service_ensure,
Expand All @@ -45,6 +49,12 @@
$plugins = undef,
) inherits kibana4::params {

validate_bool($manage_repo)

if ($manage_repo) {
validate_string($package_repo_version)
}

class {'kibana4::install': }->
class {'kibana4::config': }->
class {'kibana4::service': }
Expand All @@ -55,5 +65,4 @@
validate_hash($plugins)
create_resources('kibana4::plugin', $plugins)
}

}
6 changes: 3 additions & 3 deletions manifests/install/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
class kibana4::install::package {

if ($kibana4::manage_repo) {

case $::osfamily {

'RedHat': {
Expand Down Expand Up @@ -40,13 +42,11 @@
default: {
fail("${::operatingsystem} not supported")
}

}

}

package { 'kibana4':
ensure => $kibana4::version,
name => kibana,
}

}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class kibana4::params {
$babel_cache_path = '/tmp/babel.cache'
$version = 'latest'
$manage_repo = true
$package_repo_version = '4.5'
$package_install_dir = '/opt/kibana'
$service_ensure = true
Expand Down
28 changes: 28 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,32 @@
it { is_expected.to contain_service('kibana4').with_ensure('true').with_enable('true') }
end

context 'with manage_repo unspecified' do
let :facts do
{
:osfamily => 'RedHat'
}
end
let :params do
{
:package_repo_version => '4.5',
}
end
it { is_expected.to contain_yumrepo('kibana-4.5') }
end

context 'with manage_repo set to false' do
let :facts do
{
:osfamily => 'RedHat'
}
end
let :params do
{
:manage_repo => false,
:package_repo_version => '4.5',
}
end
it { is_expected.to_not contain_yumrepo('kibana-4.5') }
end
end

0 comments on commit bd11f06

Please sign in to comment.