Skip to content

Commit

Permalink
add support for installation via RPM
Browse files Browse the repository at this point in the history
  • Loading branch information
knackaron authored and aronparsons committed May 12, 2016
1 parent 3173003 commit bf2b00d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 47 deletions.
11 changes: 10 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
# Boolean.
# Default: true
#
# [*package_source*]
# String. Install from tarball or RPM
# Default: tar
#
# === Examples
#
# * Installation:
Expand Down Expand Up @@ -115,6 +119,7 @@
$verify_ssl = $::kibana::params::verify_ssl,
$base_path = $::kibana::params::base_path,
$log_file = $::kibana::params::log_file,
$package_source = $::kibana::params::package_source,
) inherits kibana::params {

if !is_integer($port) {
Expand All @@ -140,7 +145,11 @@
validate_absolute_path($ssl_key_file)
}

class { '::kibana::install': } ->
validate_re('^tar|rpm$', $package_source)

class { '::kibana::install':
package_source => $package_source,
} ->
class { '::kibana::config': } ~>
class { '::kibana::service': }

Expand Down
98 changes: 52 additions & 46 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
#
class kibana::install (
$package_source = $::kibana::package_source,
$version = $::kibana::version,
$base_url = $::kibana::base_url,
$tmp_dir = $::kibana::tmp_dir,
Expand All @@ -12,11 +13,6 @@
$user = $::kibana::user,
) {

$filename = $::architecture ? {
/(i386|x86$)/ => "kibana-${version}-linux-x86",
/(amd64|x86_64)/ => "kibana-${version}-linux-x64",
}

$service_provider = $::kibana::params::service_provider
$run_path = $::kibana::params::run_path

Expand All @@ -33,65 +29,69 @@
require => Group[$group],
}

wget::fetch { 'kibana':
source => "${base_url}/${filename}.tar.gz",
destination => "${tmp_dir}/${filename}.tar.gz",
require => User[$user],
unless => "test -e ${install_path}/${filename}/LICENSE.txt",
}
if $package_source == 'tar' {
$filename = $::architecture ? {
/(i386|x86$)/ => "kibana-${version}-linux-x86",
/(amd64|x86_64)/ => "kibana-${version}-linux-x64",
}

exec { 'extract_kibana':
command => "tar -xzf ${tmp_dir}/${filename}.tar.gz -C ${install_path}",
path => ['/bin', '/sbin'],
creates => "${install_path}/${filename}",
notify => Exec['ensure_correct_permissions'],
require => Wget::Fetch['kibana'],
}
wget::fetch { 'kibana':
source => "${base_url}/${filename}.tar.gz",
destination => "${tmp_dir}/${filename}.tar.gz",
require => User[$user],
unless => "test -e ${install_path}/${filename}/LICENSE.txt",
}

exec { 'ensure_correct_permissions':
command => "chown -R ${user}:${group} ${install_path}/${filename}",
path => ['/bin', '/sbin'],
refreshonly => true,
require => [
Exec['extract_kibana'],
User[$user],
],
}
exec { 'extract_kibana':
command => "tar -xzf ${tmp_dir}/${filename}.tar.gz -C ${install_path}",
path => ['/bin', '/sbin'],
creates => "${install_path}/${filename}",
notify => Exec['ensure_correct_permissions'],
require => Wget::Fetch['kibana'],
}

file { "${install_path}/kibana":
ensure => 'link',
target => "${install_path}/${filename}",
require => Exec['extract_kibana'],
}
exec { 'ensure_correct_permissions':
command => "chown -R ${user}:${group} ${install_path}/${filename}",
path => ['/bin', '/sbin'],
refreshonly => true,
require => [
Exec['extract_kibana'],
User[$user],
],
}

file { "${install_path}/kibana/installedPlugins":
ensure => directory,
owner => kibana,
group => kibana,
require => User['kibana'],
}
file { "${install_path}/kibana":
ensure => 'link',
target => "${install_path}/${filename}",
require => Exec['extract_kibana'],
}

file { '/var/log/kibana':
ensure => directory,
owner => kibana,
group => kibana,
require => User['kibana'],
file { "${install_path}/kibana/installedPlugins":
ensure => directory,
owner => kibana,
group => kibana,
require => User['kibana'],
}

} elsif $package_source == 'rpm' {
ensure_packages(['kibana'])

Package['kibana'] -> User[$user]
Package['kibana'] -> Group[$group]
Package['kibana'] -> File['kibana-init-script']
}

if $service_provider == 'init' {

file { 'kibana-init-script':
ensure => file,
path => '/etc/init.d/kibana',
content => template('kibana/kibana.legacy.service.lsbheader.erb', "kibana/${::kibana::params::init_script_osdependend}", 'kibana/kibana.legacy.service.maincontent.erb'),
mode => '0755',
notify => Class['::kibana::service'],
}

}

if $service_provider == 'systemd' {

file { 'kibana-init-script':
ensure => file,
path => "${::kibana::params::systemd_provider_path}/kibana.service",
Expand All @@ -116,4 +116,10 @@
}
}

file { '/var/log/kibana':
ensure => directory,
owner => kibana,
group => kibana,
require => User['kibana'],
}
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
$user = 'kibana'
$base_path = undef
$log_file = '/var/log/kibana/kibana.log'
$package_source = 'tar'

case $::operatingsystem {
'RedHat', 'CentOS', 'Fedora', 'Scientific', 'OracleLinux', 'SLC': {
Expand Down

0 comments on commit bf2b00d

Please sign in to comment.