From 9d4e04fc0cb11df34853d7d27bad2931a2262f38 Mon Sep 17 00:00:00 2001 From: Sean McKinley Date: Wed, 22 Jul 2015 18:04:18 -0700 Subject: [PATCH] Allows for the override of group and user.. Also ensures that /opt/kibana- has the correct ownership, as on our Centos 6.6 boxes it was ending up with a uid of 501 and a group of 'games'. --- manifests/install.pp | 16 ++++++++++++---- manifests/params.pp | 4 +++- spec/classes/install_spec.rb | 22 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index ad496e9..75b0b45 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -12,6 +12,8 @@ $base_url = $::kibana::base_url, $tmp_dir = $::kibana::tmp_dir, $install_path = $::kibana::install_path, + $group = $::kibana::group, + $user = $::kibana::user, ) { $filename = $::architecture ? { @@ -20,17 +22,17 @@ } $service_provider = $::kibana::params::service_provider - group { 'kibana': + group { $group: ensure => 'present', system => true, } - user { 'kibana': + user { $user: ensure => 'present', system => true, - gid => 'kibana', + gid => $group, home => $install_path, - require => Group['kibana'], + require => Group[$group], } wget::fetch { 'kibana': @@ -45,6 +47,12 @@ require => Wget::Fetch['kibana'], } + exec { 'ensure_correct_permissions': + command => "chown -R ${user}:${group} ${install_path}/${filename}", + path => ['/bin', '/sbin'], + require => Exec['extract_kibana'], + } + file { "${install_path}/kibana": ensure => 'link', target => "${install_path}/${filename}", diff --git a/manifests/params.pp b/manifests/params.pp index e3acf93..946f360 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -8,7 +8,7 @@ # * Justin Lambert # class kibana::params { - + $version = '4.0.1' $base_url = 'https://download.elasticsearch.org/kibana/kibana' $install_path = '/opt' @@ -21,6 +21,8 @@ $default_app_id = 'discover' $request_timeout = 300000 $shard_timeout = 0 + $group = 'kibana' + $user = 'kibana' case $::operatingsystem { 'RedHat', 'CentOS', 'Fedora', 'Scientific', 'Amazon', 'OracleLinux', 'SLC': { diff --git a/spec/classes/install_spec.rb b/spec/classes/install_spec.rb index 95b7c03..dfe0cf7 100644 --- a/spec/classes/install_spec.rb +++ b/spec/classes/install_spec.rb @@ -28,6 +28,7 @@ :destination => '/tmp/kibana-4.0.1-linux-x64.tar.gz' ) } it { should contain_exec('extract_kibana').with(:command => 'tar -xzf /tmp/kibana-4.0.1-linux-x64.tar.gz -C /opt' ) } + it { should contain_exec('ensure_correct_permissions').with(:command => 'chown -R kibana:kibana /opt/kibana-4.0.1-linux-x64', :require => "Exec[extract_kibana]") } it { should contain_file('/opt/kibana').with(:target => '/opt/kibana-4.0.1-linux-x64') } it { should contain_file('/var/log/kibana').with({ 'ensure' => 'directory', @@ -52,6 +53,27 @@ end + context 'with a different user and group' do + + let (:facts) { + default_facts.merge({ + :operatingsystemmajrelease => '7' + }) + } + + let (:params) { + { + :group => 'test_group', + :user => 'test_user', + :install_path => '/opt', + :version => '4.0.1' + } + } + + it { should contain_user('test_user') } + it { should contain_exec('ensure_correct_permissions').with(:command => 'chown -R test_user:test_group /opt/kibana-4.0.1-linux-x64', :require => "Exec[extract_kibana]") } + end + context 'when running on EL 7' do let (:facts) {