Skip to content

Commit

Permalink
Merge pull request #297 from willaerk/user_hash
Browse files Browse the repository at this point in the history
Add jenkins::users class to declare all users
  • Loading branch information
R. Tyler Croy committed May 8, 2015
2 parents ad774dc + cb097e4 commit 6e05619
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
21 changes: 20 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# config_hash => {
# 'HTTP_PORT' => { 'value' => '9090' }, 'AJP_PORT' => { 'value' => '9009' }
# }
# V
# }
#
# plugin_hash = undef (Default)
# Hash with config plugins to install
Expand Down Expand Up @@ -81,6 +81,23 @@
# 'token-macro': {}
#
#
# user_hash = {} (Default)
# Hash with users to create in jenkins
#
# Example use
#
# class{ 'jenkins':
# user_hash => {
# 'user1' => { 'password' => 'pass1',
# 'email' => '[email protected]'}
#
# Or in Hiera
#
# jenkins::user_hash:
# 'user1':
# password: 'pass1'
# email: '[email protected]'
#
# configure_firewall = undef (default)
# For folks that want to manage the puppetlabs firewall module.
# - If it's not present in the catalog, nothing happens.
Expand Down Expand Up @@ -133,6 +150,7 @@
$config_hash = {},
$plugin_hash = {},
$job_hash = {},
$user_hash = {},
$configure_firewall = undef,
$install_java = $jenkins::params::install_java,
$proxy_host = undef,
Expand Down Expand Up @@ -187,6 +205,7 @@
include jenkins::config
include jenkins::plugins
include jenkins::jobs
include jenkins::users

if $proxy_host and $proxy_port {
class { 'jenkins::proxy':
Expand Down
11 changes: 11 additions & 0 deletions manifests/users.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Class: jenkins::users
#
class jenkins::users {

if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

create_resources('jenkins::user', $::jenkins::user_hash)

}
22 changes: 22 additions & 0 deletions spec/classes/jenkins_users_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'spec_helper'

describe 'jenkins', :type => :module do
let(:facts) { { :osfamily => 'RedHat', :operatingsystem => 'RedHat' } }

context 'users' do
context 'default' do
it { should contain_class('jenkins::users') }
end

context 'with testuser' do
let(:params) {
{ :user_hash => { 'user' => {
'email' => '[email protected]',
'password' => 'test'
} } } }
it { should contain_jenkins__user('user').with_email('[email protected]').with_password('test') }
end

end

end

0 comments on commit 6e05619

Please sign in to comment.