Skip to content

Commit

Permalink
merging and updating windows changes with upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gregory.whiting committed May 18, 2016
2 parents d16800c + 53edc27 commit ad11575
Show file tree
Hide file tree
Showing 86 changed files with 2,508 additions and 1,493 deletions.
98 changes: 98 additions & 0 deletions manifests/augeas.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# == Definition jenkins::augeas
#
# === Parameters:
#
# [*config_filename*]: Filename of the configuration file to work on relative to the jenkins localstatedir.
#
# [*changes*]: String or array with augeas changes to perform.
#
# [*onlyif*]: Optional augeas command and comparisons to control the execution of this type.
#
# [*plugin*]: Optionally jenkins::augeas can also install the plugin. If this is set to true,
# we use the name of the resource as plugin name. If it's a string, that is used
# as plugin name.
#
# [*plugin_version*]: Optional plugin version to pass through to jenkins::plugin
#
# [*context*]: Optional context to ease your change rules.
#
# [*restart*]: If set to true, will trigger a jenkins (safe-)restart in stead of reloading
# the configuration.
#
# === Example:
#
# jenkins::augeas {'git':
# plugin => true,
# config_filename => 'hudson.plugins.git.GitSCM.xml',
# context => '/hudson.plugins.git.GitSCM_-DescriptorImpl',
# changes => [
# 'set globalConfigName/#text "Bob the Builder"',
# 'set globalConfigEmail/#text "[email protected]",
# ],
# }
#
#
#
define jenkins::augeas (
$config_filename,
$changes,
$onlyif = undef,
$context = '/',
$plugin_version = undef,
$plugin = false,
$restart = false,
) {
validate_string($config_filename)
if ! is_string($changes) and ! is_array($changes) {
fail('$changes must be string or array.')
}
if ! is_string($onlyif) and ! is_array($onlyif) {
fail('$onlyif must be string or array.')
}
validate_string($context)
validate_string($plugin_version)
if ! is_bool($plugin) and ! is_string($plugin) {
fail('$plugin must be bool or string.')
}
validate_bool($restart)

include ::jenkins
include ::jenkins::cli


case $plugin {
true: {
jenkins::plugin {$name:
version => $plugin_version,
manage_config => false,
before => Augeas["jenkins::augeas: ${name}"],
}
}
false: {
# do nothing
}
default: {
jenkins::plugin {$plugin:
version => $plugin_version,
manage_config => false,
before => Augeas["jenkins::augeas: ${name}"],
}
}
}

if $restart {
$notify_exec = 'safe-restart-jenkins'
} else {
$notify_exec = 'reload-jenkins'
}

augeas {"jenkins::augeas: ${name}":
incl => "${::jenkins::localstatedir}/${config_filename}",
lens => 'Xml.lns',
context => regsubst("/files${::jenkins::localstatedir}/${config_filename}/${context}", '\/{2,}', '/', 'G'),
notify => Exec[$notify_exec],
onlyif => $onlyif,
changes => $changes,
}

}
18 changes: 15 additions & 3 deletions manifests/cli/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,37 @@
# resource face. No defaults should be set in this classes definition.
class jenkins::cli::config(
$cli_jar = undef,
$port = undef,
$url = undef,
$ssh_private_key = undef,
$puppet_helper = undef,
$cli_tries = undef,
$cli_try_sleep = undef,
$ssh_private_key_content = undef,
) {
if $cli_jar { validate_absolute_path($cli_jar) }
if $port { validate_integer($port) }
validate_string($url)
if $ssh_private_key { validate_absolute_path($ssh_private_key) }
if $puppet_helper { validate_absolute_path($puppet_helper) }
if $cli_tries { validate_integer($cli_tries) }
if $cli_try_sleep { validate_numeric($cli_try_sleep) }
validate_string($ssh_private_key_content)

if str2bool($::is_pe) {
$gem_provider = 'pe_gem'
} elsif $::puppetversion
and (versioncmp($::puppetversion, '4.0.0') >= 0)
and $::rubysitedir
and ('/opt/puppetlabs/puppet/lib/ruby' in $::rubysitedir) {
# AIO puppet
$gem_provider = 'puppet_gem'
} else {
$gem_provider = 'gem'
}

# required by PuppetX::Jenkins::Provider::Clihelper base
if ! defined(Package['retries']) {
package { 'retries':
provider => 'gem',
provider => $gem_provider,
}
}

Expand Down
29 changes: 20 additions & 9 deletions manifests/cli_helper.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
#
# A helper script for creating resources via the Jenkins cli
#
class jenkins::cli_helper {
# Parameters:
#
# ssh_keyfile = undef
# Defaults to the value of $::jenkins::cli_ssh_keyfile. This parameter is
# deprecated, please set $::jenkins::cli_ssh_keyfile instead of setting this
# directly
#
class jenkins::cli_helper (
$ssh_keyfile = $::jenkins::cli_ssh_keyfile,
) {
include ::jenkins
include ::jenkins::cli

$bin_path = $::jenkins::javapath
#$bin_path = $osfamily ? {
# 'Windows' => '',
# default => '/usr/bin/',
#}
if $ssh_keyfile { validate_absolute_path($ssh_keyfile) }

Class['jenkins::cli'] ->
Class['jenkins::cli_helper'] ->
Anchor['jenkins::end']
Expand All @@ -19,9 +26,9 @@
$cli_jar = "${::jenkins::cli::jar}"
$port = jenkins_port()
$prefix = jenkins_prefix()

$helper_groovy = "${libdir}/puppet_helper.groovy"
file {$helper_groovy:

file { $helper_groovy:
source => 'puppet:///modules/jenkins/puppet_helper.groovy',
owner => $::jenkins::user,
group => $::jenkins::group,
Expand All @@ -30,12 +37,16 @@
}

# Provide the -i flag if specified by the user.
if $::jenkins::cli_ssh_keyfile {
$auth_arg = "-i ${::jenkins::cli_ssh_keyfile}"
if $ssh_keyfile {
$auth_arg = "-i ${ssh_keyfile}"
} else {
$auth_arg = undef
}

if $ssh_keyfile != $::jenkins::cli_ssh_keyfile {
info("Using jenkins::cli_helper(${ssh_keyfile}) is deprecated and will be removed in the next major version of this module")
}

$helper_cmd = join(
delete_undef_values([
"${bin_path}java",
Expand Down
8 changes: 5 additions & 3 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
})
}

ensure_resource('file', $::jenkins::localstatedir, $dir_params)
ensure_resource('file', $::jenkins::plugin_dir, $dir_params)
ensure_resource('file', $::jenkins::job_dir, $dir_params)
if $::jenkins::manage_datadirs {
ensure_resource('file', $::jenkins::localstatedir, $dir_params)
ensure_resource('file', $::jenkins::plugin_dir, $dir_params)
ensure_resource('file', $::jenkins::job_dir, $dir_params)
}
}
6 changes: 5 additions & 1 deletion manifests/credentials.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
$ensure = 'present',
$uuid = '',
){
validate_string($ensure)
validate_string($password)
validate_string($description)
validate_string($private_key_or_path)
validate_re($ensure, '^present$|^absent$')
validate_string($uuid)

include ::jenkins::cli_helper

Expand Down
11 changes: 7 additions & 4 deletions manifests/direct_download.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@

if $::jenkins::version != 'absent' {
# make download optional if we are removing...
staging::file { $package_file:
source => $jenkins::direct_download,
target => $local_file,
before => Package[$::jenkins::package_name],
archive { $package_file:
source => $jenkins::direct_download,
path => $local_file,
proxy_server => $::jenkins::proxy_server,
cleanup => false,
extract => false,
before => Package[$::jenkins::package_name],
}
}

Expand Down
Loading

0 comments on commit ad11575

Please sign in to comment.