Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability to supply a non-default user, a uid, and a non-default group. #45

Merged
merged 1 commit into from
Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? {
Expand All @@ -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':
Expand All @@ -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}",
Expand Down
4 changes: 3 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# * Justin Lambert <mailto:[email protected]>
#
class kibana::params {

$version = '4.0.1'
$base_url = 'https://download.elasticsearch.org/kibana/kibana'
$install_path = '/opt'
Expand All @@ -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': {
Expand Down
22 changes: 22 additions & 0 deletions spec/classes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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) {
Expand Down