Skip to content

Commit

Permalink
Merge pull request voxpupuli#52 from matthewbarr/params
Browse files Browse the repository at this point in the history
Params.pp & puppetlabs/java dependency, and other fixes
  • Loading branch information
matthewbarr committed Oct 10, 2013
2 parents 5066574 + ca78023 commit 7a66f3f
Show file tree
Hide file tree
Showing 20 changed files with 271 additions and 175 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ fixtures:
repositories:
apt: "git://github.com/puppetlabs/puppetlabs-apt"
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib"
java: "git://github.com/puppetlabs/puppetlabs-java"
symlinks:
"jenkins": "#{source_dir}"
5 changes: 3 additions & 2 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name 'rtyler-jenkins'
version '0.2.4'
source 'git://github.com/rtyler/puppet-jenkins.git'
source 'git://github.com/jenkinsci/puppet-jenkins.git'
author 'R. Tyler Croy <[email protected]>'
license 'Apache 2.0'
summary 'Manage the Jenkins continuous integration service with Puppet'
description 'Manage the Jenkins continuous integration service with Puppet'
project_page 'https://github.com/rtyler/puppet-jenkins'
project_page 'https://github.com/jenkinsci/puppet-jenkins'

## Add dependencies, if any:
dependency 'puppetlabs/stdlib', '>= 2.0.0'
dependency 'puppetlabs/apt', '>= 0.0.3'
dependency 'puppetlabs/java', '>= 1.0.1'
5 changes: 4 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ It requires the swarm plugin on the master & the class jenkins::slave on the sla
node /jenkins-master.*/ {
include jenkins
jenkins::plugin {'swarm':}
include jenkins::master
}
```

Expand All @@ -73,6 +73,7 @@ The dependencies for this module currently are:

* [stdlib module](http://forge.puppetlabs.com/puppetlabs/stdlib)
* [apt module](http://forge.puppetlabs.com/puppetlabs/apt) (for Debian/Ubuntu users)
* [java module](http://github.com/puppetlabs/puppetlabs-java)



Expand All @@ -94,6 +95,7 @@ the following `require` statement:
3. Configure Firewall - jenkins (init.pp)
4. Outbound Jenkins Proxy Config - jenkins (init.pp)


## Using from Github / source

### With librarian
Expand Down Expand Up @@ -127,6 +129,7 @@ of this module, please use the `rake build` task. The resulting package file
may be uploaded to the [Puppet Forge](http://forge.puppetlabs.com/).



To quickly try this module with the puppet module tool:

% rake build
Expand Down
89 changes: 63 additions & 26 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Parameters:

# version = 'installed' (Default)
# Will NOT update jenkins to the most recent version.
# version = 'latest'
# Will automatically update the version of jenkins to the current version available via your pacakge manager.
#
# lts = 0 (Default)
# lts = false (Default)
# Use the most up to date version of jenkins
#
# lts = 1
# lts = true
# Use LTS verison of jenkins
#
# repo = 1 (Default)
# repo = true (Default)
# install the jenkins repo.
#
# repo = 0
Expand Down Expand Up @@ -54,34 +55,57 @@
# 'git-client': {}
# 'token-macro': {}
#
#
# configure_firewall = true (default)
# For folks that want to manage the puppetlabs firewall module.
# - If it's not present, it will not be installed and nothing happens
# - This default could change in the future.
#
#
# installl_java = true (Default)
# - use puppetlabs-java module to install the correct version of a JDK.
# - Jenkins requires a JRE
#
class jenkins(
$version = 'installed',
$lts = 0,
$repo = 1,
$config_hash = undef,
$plugin_hash = undef,
$configure_firewall = true,
$proxy_host = undef,
$proxy_port = undef,
) {
$version = $jenkins::params::version,
$lts = $jenkins::params::lts,
$repo = $jenkins::params::repo,
$config_hash = undef,
$plugin_hash = undef,
$configure_firewall = $jenkins::params::configure_firewall,
$install_java = $jenkins::params::install_java,
$proxy_host = undef,
$proxy_port = undef,
) inherits jenkins::params {

$lts_real = str2bool($lts)
$java_real = str2bool($install_java)
$repo_real = str2bool($repo)
$firewall_real = str2bool($configure_firewall)

anchor {'jenkins::begin':}
anchor {'jenkins::end':}

class {'jenkins::repo':
lts => $lts,
repo => $repo;
if $java_real {
class {'java':
distribution => 'jdk'
}
}

if $repo_real {
class {'jenkins::repo':}
}

class {'jenkins::package' :
version => $version;
version => $version;
}

class { 'jenkins::config':
config_hash => $config_hash,
config_hash => $config_hash,
}

class { 'jenkins::plugins':
plugin_hash => $plugin_hash,
plugin_hash => $plugin_hash,
}

if $proxy_host {
Expand All @@ -95,19 +119,32 @@

class {'jenkins::service':}

if ($configure_firewall){
if $firewall_real {
class {'jenkins::firewall':}
}

Anchor['jenkins::begin'] ->
Class['jenkins::repo'] ->
Class['jenkins::package'] ->
Class['jenkins::config'] ->
Class['jenkins::plugins']~>
Class['jenkins::service'] ->
Anchor['jenkins::end']
Class['jenkins::package'] ->
Class['jenkins::config'] ->
Class['jenkins::plugins']~>
Class['jenkins::service'] ->
Anchor['jenkins::end']

if $java_real {
Anchor['jenkins::begin'] ->
Class['java'] ->
Class['jenkins::package'] ->
Anchor['jenkins::end']
}

if $repo {
Anchor['jenkins::begin'] ->
Class['jenkins::repo'] ->
Class['jenkins::package'] ->
Anchor['jenkins::end']
}

if $configure_firewall {
if $firewall_real {
Class['jenkins::service'] ->
Class['jenkins::firewall'] ->
Anchor['jenkins::end']
Expand Down
10 changes: 10 additions & 0 deletions manifests/master.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Class: jenkins::master
#
#
class jenkins::master (
$version = $jenkins::params::swarm_version
) inherits jenkins::params {

jenkins::plugin {'swarm':
version => $version }
}
11 changes: 11 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Class: jenkins::params
#
#
class jenkins::params {
$version = 'installed'
$lts = false
$repo = true
$configure_firewall = true
$install_java = true
$swarm_version = '1.9'
}
6 changes: 4 additions & 2 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@
if (!defined(Group['jenkins'])) {
group {
'jenkins' :
ensure => present;
ensure => present,
require => Package['jenkins'];
}
}

if (!defined(User['jenkins'])) {
user {
'jenkins' :
ensure => present;
ensure => present,
require => Package['jenkins'];
}
}

Expand Down
6 changes: 2 additions & 4 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#
# jenkins::repo handles pulling in the platform specific repo classes
#
class jenkins::repo ($lts=0, $repo=1) {
class jenkins::repo {
# JJM These anchors work around #8040
anchor { 'jenkins::repo::alpha': }
anchor { 'jenkins::repo::omega': }

if ($repo == 1) {
if ( $::jenkins::repo_real ) {
case $::osfamily {

'RedHat', 'Linux': {
class {
'jenkins::repo::el':
lts => $lts,
require => Anchor['jenkins::repo::alpha'],
before => Anchor['jenkins::repo::omega'],
}
Expand All @@ -21,7 +20,6 @@
'Debian': {
class {
'jenkins::repo::debian':
lts => $lts,
require => Anchor['jenkins::repo::alpha'],
before => Anchor['jenkins::repo::omega'],
}
Expand Down
20 changes: 9 additions & 11 deletions manifests/repo/debian.pp
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
# Class: jenkins::repo::debian
#
class jenkins::repo::debian ( $lts=0 )
class jenkins::repo::debian
{

include 'jenkins::repo'

if $lts == 0 {
if $::jenkins::lts_real {
apt::source { 'jenkins':
location => 'http://pkg.jenkins-ci.org/debian',
location => 'http://pkg.jenkins-ci.org/debian-stable',
release => 'binary/',
repos => '',
key => 'D50582E6',
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
include_src => false,
}
}

}
elsif $lts == 1 {
else {
apt::source { 'jenkins':
location => 'http://pkg.jenkins-ci.org/debian-stable',
location => 'http://pkg.jenkins-ci.org/debian',
release => 'binary/',
repos => '',
key => 'D50582E6',
key_source => 'http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key',
include_src => false,
}
}

}



15 changes: 6 additions & 9 deletions manifests/repo/el.pp
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
# Class: jenkins::repo::el
#
class jenkins::repo::el ( $lts=0 )
class jenkins::repo::el
{

include 'jenkins::repo'

if $lts == 0 {
if $::jenkins::lts_real {
yumrepo {'jenkins':
descr => 'Jenkins',
baseurl => 'http://pkg.jenkins-ci.org/redhat/',
baseurl => 'http://pkg.jenkins-ci.org/redhat-stable/',
gpgcheck => 1,
gpgkey => 'http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key'
}
}
elsif $lts == 1 {

else {
yumrepo {'jenkins':
descr => 'Jenkins',
baseurl => 'http://pkg.jenkins-ci.org/redhat-stable/',
baseurl => 'http://pkg.jenkins-ci.org/redhat/',
gpgcheck => 1,
gpgkey => 'http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key'
}
}

}

Loading

0 comments on commit 7a66f3f

Please sign in to comment.