Skip to content

Commit

Permalink
add parameter manage_user
Browse files Browse the repository at this point in the history
which defines if user and group should be managed by this module. This gives
you the possibility to manage the user and group with another module or
manually.

The default value is set to true so it doesn't change the existent behaviour
of this module.
  • Loading branch information
n00by authored and arioch committed Feb 16, 2016
1 parent a6cb422 commit eb61819
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 11 deletions.
25 changes: 14 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
$config_dir_purge = $::icingaweb2::config_dir_purge,
$web_root = $::icingaweb2::web_root,
) {
@user { 'icingaweb2':
ensure => present,
home => $::icingaweb2::web_root,
managehome => true,
}

@group { 'icingaweb2':
ensure => present,
system => true,
}
if $::icingaweb2::manage_user {
@user { 'icingaweb2':
ensure => present,
home => $::icingaweb2::web_root,
managehome => true,
}

realize(User['icingaweb2'])
realize(Group['icingaweb2'])
@group { 'icingaweb2':
ensure => present,
system => true,
}

realize(User['icingaweb2'])
realize(Group['icingaweb2'])
}

File {
require => Class['::icingaweb2::install'],
Expand Down
7 changes: 7 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
# $manage_repo:: Add a custom package repository.
# Default: false.
#
# $manage_user:: Defines if user and group should be managed
# by this module. Set to false if you don't want
# user and group to be managed by this module.
# Default: true.
#
# $pkg_deps:: Any dependencies that need to be resolved before
# installing the main package.
# Default: operating system specific.
Expand Down Expand Up @@ -195,6 +200,7 @@
$log_store = $::icingaweb2::params::log_store,
$manage_apache_vhost = $::icingaweb2::params::manage_apache_vhost,
$manage_repo = $::icingaweb2::params::manage_repo,
$manage_user = $::icingaweb2::params::manage_user,
$pkg_deps = $::icingaweb2::params::pkg_deps,
$pkg_ensure = $::icingaweb2::params::pkg_ensure,
$pkg_list = $::icingaweb2::params::pkg_list,
Expand Down Expand Up @@ -233,6 +239,7 @@
validate_array($pkg_list)
validate_bool($config_dir_recurse)
validate_bool($manage_repo)
validate_bool($manage_user)
validate_bool($initialize)
validate_slength($config_dir_mode, 4)
validate_slength($config_file_mode, 4)
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$install_method = 'git'
$manage_apache_vhost = false
$manage_repo = false
$manage_user = true

# Template variables
$admin_permissions = '*'
Expand Down
16 changes: 16 additions & 0 deletions spec/classes/icingaweb2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,22 @@
end
end

describe 'icingaweb2::manage_user' do
context 'with manage_user => true' do
let (:params) { { :manage_user => true } }

it { should contain_user('icingaweb2') }
it { should contain_group('icingaweb2') }
end

context 'with manage_user => false' do
let (:params) { { :manage_user => false } }

it { should_not contain_user('icingaweb2') }
it { should_not contain_group('icingaweb2') }
end
end

describe 'with parameter: pkg_ensure' do
let (:params) {
{
Expand Down

0 comments on commit eb61819

Please sign in to comment.