Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

(RFC - not ready for merge) use camptocamp/archive for all downloads #340

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions manifests/direct_download.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,24 @@
validate_absolute_path($local_file)

if $::jenkins::version != 'absent' {
$enable_checksum = $::jenkins::direct_download_checksum ? {
undef => false,
default => true,
}

# make download optional if we are removing...
staging::file { $package_file:
source => $jenkins::direct_download,
target => $local_file,
before => Package[$::jenkins::package_name],
archive::download { $package_file:
url => $::jenkins::direct_download,
src_target => $::jenkins::package_cache_dir,
allow_insecure => true,
follow_redirects => true,
checksum => $enable_checksum,
digest_string => $::jenkins::direct_download_checksum,
digest_type => $::jenkins::direct_download_checksum_type,
proxy_server => $::jenkins::http_proxy,
verbose => false,
require => File[$::jenkins::package_cache_dir],
before => Package[$::jenkins::package_name],
}
}

Expand Down
61 changes: 36 additions & 25 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -140,31 +140,33 @@
#
#
class jenkins(
$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 = {},
$plugin_hash = {},
$job_hash = {},
$user_hash = {},
$configure_firewall = undef,
$install_java = $jenkins::params::install_java,
$repo_proxy = undef,
$proxy_host = undef,
$proxy_port = undef,
$no_proxy_list = undef,
$cli = undef,
$cli_tries = $jenkins::params::cli_tries,
$cli_try_sleep = $jenkins::params::cli_try_sleep,
$port = $jenkins::params::port,
$libdir = $jenkins::params::libdir,
$executors = undef,
$version = $jenkins::params::version,
$lts = $jenkins::params::lts,
$repo = $jenkins::params::repo,
$package_name = $jenkins::params::package_name,
$direct_download = false,
$direct_download_checksum = undef,
$direct_download_checksum_type = 'sha1',
$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 = {},
$plugin_hash = {},
$job_hash = {},
$user_hash = {},
$configure_firewall = undef,
$install_java = $jenkins::params::install_java,
$repo_proxy = undef,
$proxy_host = undef,
$proxy_port = undef,
$no_proxy_list = undef,
$cli = undef,
$cli_tries = $jenkins::params::cli_tries,
$cli_try_sleep = $jenkins::params::cli_try_sleep,
$port = $jenkins::params::port,
$libdir = $jenkins::params::libdir,
$executors = undef,
) inherits jenkins::params {

validate_bool($lts, $install_java, $repo)
Expand All @@ -182,6 +184,12 @@
validate_integer($executors)
}

if ($jenkins::proxy_host) {
$http_proxy = "http://${jenkins::proxy_host}:${jenkins::proxy_port}/"
} else {
$http_proxy = undef
}

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

Expand All @@ -205,6 +213,9 @@
}
include $jenkins_package_class

validate_string($direct_download_checksum)
validate_string($direct_download_checksum_type)

include jenkins::config
include jenkins::plugins
include jenkins::jobs
Expand Down
30 changes: 12 additions & 18 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
$enabled = true,
$create_user = true,
$source = undef,
$digest_string = '',
$digest_type = 'sha1',
$checksum = undef,
$checksum_type = 'sha1',
) {
include ::jenkins::params

Expand All @@ -38,8 +38,8 @@
validate_bool($enabled)
# TODO: validate_str($update_url)
validate_string($source)
validate_string($digest_string)
validate_string($digest_type)
validate_string($checksum)
validate_string($checksum_type)

if ($version != 0) {
$plugins_host = $update_url ? {
Expand Down Expand Up @@ -103,12 +103,6 @@
}

if (empty(grep([ $::jenkins_plugins ], $search))) {
if ($jenkins::proxy_host) {
$proxy_server = "${jenkins::proxy_host}:${jenkins::proxy_port}"
} else {
$proxy_server = undef
}

$enabled_ensure = $enabled ? {
false => present,
default => absent,
Expand Down Expand Up @@ -150,22 +144,22 @@
default => $source,
}

if $digest_string == '' {
$checksum = false
} else {
$checksum = true
$enable_checksum = $checksum ? {
undef => false,
default => true,
}

archive::download { $plugin:
url => $download_url,
src_target => $plugin_dir,
allow_insecure => true,
follow_redirects => true,
checksum => $checksum,
digest_string => $digest_string,
digest_type => $digest_type,
checksum => $enable_checksum,
digest_string => $checksum,
digest_type => $checksum_type,
user => $username,
proxy_server => $proxy_server,
proxy_server => $::jenkins::http_proxy,
verbose => false,
notify => Service['jenkins'],
require => File[$plugin_dir],
}
Expand Down
37 changes: 24 additions & 13 deletions manifests/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
$slave_name = undef,
$description = undef,
$masterurl = undef,
$autodiscoveryaddress = undef,
$autodiscoveryaddress = undef,
$ui_user = undef,
$ui_pass = undef,
$version = $jenkins::params::swarm_version,
Expand All @@ -92,8 +92,12 @@
$tool_locations = undef,
$install_java = $jenkins::params::install_java,
$ensure = 'running',
$enable = true
$enable = true,
$checksum = undef,
$checksum_type = 'sha1',
) inherits jenkins::params {
validate_string($checksum)
validate_string($checksum_type)

$client_jar = "swarm-client-${version}-jar-with-dependencies.jar"
$client_url = "http://maven.jenkins-ci.org/content/repositories/releases/org/jenkins-ci/plugins/swarm-client/${version}/"
Expand Down Expand Up @@ -126,16 +130,26 @@
}
}

exec { 'get_swarm_client':
command => "wget -O ${slave_home}/${client_jar} ${client_url}/${client_jar}",
path => '/usr/bin:/usr/sbin:/bin:/usr/local/bin',
user => $slave_user,
#refreshonly => true,
creates => "${slave_home}/${client_jar}",
## needs to be fixed if you create another version..
$enable_checksum = $checksum ? {
undef => false,
default => true,
}

# customizations based on the OS family
archive::download { $client_jar:
url => "${client_url}/${client_jar}",
src_target => $slave_home,
allow_insecure => true,
follow_redirects => true,
checksum => $enable_checksum,
digest_string => $checksum,
digest_type => $checksum_type,
user => $slave_user,
proxy_server => $::jenkins::http_proxy,
verbose => false,
notify => Service['jenkins-slave'],
}

# customizations based on the OS family
case $::osfamily {
'Debian': {
$defaults_location = '/etc/default'
Expand Down Expand Up @@ -175,9 +189,6 @@
hasrestart => true,
}

Exec['get_swarm_client']
-> Service['jenkins-slave']

if $install_java {
Class['java'] ->
Service['jenkins-slave']
Expand Down
3 changes: 1 addition & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
{ "name": "puppetlabs/apt", "version_requirement": ">= 0.0.3 < 3.0.0" },
{ "name": "puppetlabs/java", "version_requirement": ">= 1.0.1 < 2.0.0" },
{ "name": "darin/zypprepo", "version_requirement": ">= 1.0.1 < 2.0.0" },
{ "name": "nanliu/staging", "version_requirement": ">= 1.0.0 < 2.0.0" },
{ "name": "camptocamp/archive", "version_requirement": ">= 0.8.0" }
{ "name": "camptocamp/archive", "version_requirement": ">= 0.8.0 < 1.0.0" }
]
}