Skip to content

Commit

Permalink
initial support for direct download package installation
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Williams committed Mar 17, 2015
1 parent 29421c4 commit 948c119
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 11 deletions.
3 changes: 0 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

include jenkins::package

Class['Jenkins::Package']->Class['Jenkins::Config']
create_resources( 'jenkins::sysconfig', $::jenkins::config_hash )
}

38 changes: 38 additions & 0 deletions manifests/direct_download.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Support for directly downloading a package file - for when no repository
# is available
#
class jenkins::direct_download {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}

validate_string($::jenkins::package_provider)
validate_string($::jenkins::direct_download)
validate_absolute_path($::jenkins::package_cache_dir)
if $::jenkins::version {
validate_string($::jenkins::version)
}

# stdlib 4.6 has 'basename'
#$package_file = basename($::jenkins::download_url)
$package_file = regsubst($::jenkins::direct_download, '(.*?)([^/]+)$', '\2')
$local_file = "${::jenkins::package_cache_dir}/${package_file}"

validate_absolute_path($local_file)

if $::jenkins::version {
# make download optional if we are removing...
staging::file { $package_file:
source => $jenkins::direct_download,
target => $local_file,
before => Package[$::jenkins::package_name],
}
}

package { $::jenkins::package_name:
ensure => $::jenkins::version,
provider => $::jenkins::package_provider,
source => $local_file,
}
}
39 changes: 34 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
# this module.
# This is for folks that use a custom repo, or the like.
#
# package_name = 'jenkins'
# Optionally override the package name
#
# direct_download = 'http://...'
# Ignore repostory based package installation and download and install
# package directly. Leave as `false` (the default) to download using your
# OS package manager
#
# package_cache_dir = '/var/cache/jenkins_pkgs'
# Optionally specify an alternate location to download packages to when using
# direct_download
#
# service_enable = true (default)
# Enable (or not) the jenkins service
#
Expand Down Expand Up @@ -109,6 +121,10 @@
$version = $jenkins::params::version,
$lts = $jenkins::params::lts,
$repo = $jenkins::params::repo,
$package_name = $jenkins::params::package_name,
$direct_download = false,
$package_cache_dir = $jenkins::params::package_cache_dir,
$package_provider = $jenkins::params::package_provider,
$service_enable = $jenkins::params::service_enable,
$service_ensure = $jenkins::params::service_ensure,
$config_hash = {},
Expand Down Expand Up @@ -146,11 +162,24 @@
}
}

if $repo {
if ! $direct_download and $repo {
include jenkins::repo
$repo_ = true
} elsif direct_download {
$repo_ = false
file { $package_cache_dir:
ensure => directory,
owner => "root",
group => "root",
mode => "0644",
}
include jenkins::direct_download
$jenkins_package_class = 'jenkins::direct_download'
} else {
include jenkins::package
$jenkins_package_class = 'jenkins::package'
}

include jenkins::package
include jenkins::config
include jenkins::plugins
include jenkins::jobs
Expand All @@ -177,7 +206,7 @@
}

Anchor['jenkins::begin'] ->
Class['jenkins::package'] ->
Class[$jenkins_package_class] ->
Class['jenkins::config'] ->
Class['jenkins::plugins'] ~>
Class['jenkins::service'] ->
Expand All @@ -195,11 +224,11 @@
if $install_java {
Anchor['jenkins::begin'] ->
Class['java'] ->
Class['jenkins::package'] ->
Class[$jenkins_package_class] ->
Anchor['jenkins::end']
}

if $repo {
if $repo_ {
Anchor['jenkins::begin'] ->
Class['jenkins::repo'] ->
Class['jenkins::package'] ->
Expand Down
4 changes: 2 additions & 2 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
fail("Use of private class ${name} by ${caller_module_name}")
}

package { 'jenkins' :
ensure => $::jenkins::version;
package { $::jenkins::package_name:
ensure => $::jenkins::version,
}
}
9 changes: 8 additions & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
$port = '8080'
$cli_tries = 10
$cli_try_sleep = 10
$package_cache_dir = '/var/cache/jenkins_pkgs'
$package_name = 'jenkins'

case $::osfamily {
'Debian': {
$libdir = '/usr/share/jenkins'
$libdir = '/usr/share/jenkins'
$package_provider = 'dpkg'
}
'RedHat': {
$libdir = '/usr/lib/jenkins'
$package_provider = 'rpm'
}
default: {
$libdir = '/usr/lib/jenkins'
Expand Down

0 comments on commit 948c119

Please sign in to comment.