Skip to content
Open
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
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
$nexus_manage_user = $nexus::params::nexus_manage_user,
$nexus_data_folder = $nexus::params::nexus_data_folder,
$download_folder = $nexus::params::download_folder,
$download_provider = $nexus::params::download_provider,
$manage_config = $nexus::params::manage_config,
$md5sum = $nexus::params::md5sum,
) inherits nexus::params {
Expand Down Expand Up @@ -106,6 +107,7 @@
revision => $revision,
deploy_pro => $deploy_pro,
download_site => $real_download_site,
download_provider => $download_provider,
nexus_root => $nexus_root,
nexus_home_dir => $nexus_home_dir,
nexus_user => $nexus_user,
Expand Down
83 changes: 61 additions & 22 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$nexus_work_recurse = $::nexus::nexus_work_recurse,
$nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults,
$download_folder = $::nexus::download_folder,
$download_provider = $::nexus::download_provider,
$md5sum = $::nexus::md5sum,
) {

Expand All @@ -60,25 +61,64 @@
$dl_file = "${download_folder}/${nexus_archive}"
$nexus_home_real = "${nexus_root}/nexus${bundle_type}-${full_version}"

# NOTE: When setting version to 'latest' the site redirects to the latest
# release. But, nexus-latest-bundle.tar.gz will already exist and
# therefore the exec will never be triggered. In reality 'latest' will
# lock you to a version.
#
# NOTE: I *think* this won't repeatedly download the file because it's
# linked to an exec resource which won't be realized if a directory
# already exists.
wget::fetch{ $nexus_archive:
source => $download_url,
destination => $dl_file,
source_hash => $md5sum,
before => Exec['nexus-untar'],
}
case $download_provider {
'wget::fetch': {
# NOTE: When setting version to 'latest' the site redirects to the latest
# release. But, nexus-latest-bundle.tar.gz will already exist and
# therefore the exec will never be triggered. In reality 'latest' will
# lock you to a version.
#
# NOTE: I *think* this won't repeatedly download the file because it's
# linked to an exec resource which won't be realized if a directory
# already exists.
wget::fetch{ $nexus_archive:
source => $download_url,
destination => $dl_file,
source_hash => $md5sum,
before => Exec['nexus-untar'],
}

exec{ 'nexus-untar':
command => "tar zxf ${download_folder}/${nexus_archive} --directory ${nexus_root}",
creates => $nexus_home_real,
path => ['/bin','/usr/bin'],
before => File[$nexus_home_real]
}

exec{ 'nexus-untar':
command => "tar zxf ${download_folder}/${nexus_archive} --directory ${nexus_root}",
creates => $nexus_home_real,
path => ['/bin','/usr/bin'],
if $nexus_work_dir_manage == true {
Wget::Fetch[$nexus_archive] -> File[$nexus_work_dir]
}
}
'archive': {
case $md5sum {
undef: {
$md5sum_real = undef
$md5sum_type = undef
}
default: {
$md5sum_real = $md5sum
$md5sum_type = 'md5'
}
}

archive{ $dl_file:
ensure => present,
extract => true,
extract_path => $nexus_root,
source => $download_url,
checksum => $md5sum_real,
checksum_type => $md5sum_type,
creates => $nexus_home_real,
before => File[$nexus_home_real]
}

if $nexus_work_dir_manage == true {
Archive[$dl_file] -> File[$nexus_work_dir]
}
}
default: {
fail("Download_provider ${download_provider} not supported.")
}
}

# NOTE: $nexus_work_dir in later releases was moved to a directory not
Expand All @@ -89,8 +129,7 @@
owner => $nexus_user,
group => $nexus_group,
recurse => true,
selinux_ignore_defaults => $nexus_selinux_ignore_defaults,
require => Exec[ 'nexus-untar']
selinux_ignore_defaults => $nexus_selinux_ignore_defaults
}


Expand All @@ -103,7 +142,7 @@
group => $nexus_group,
recurse => $nexus_work_recurse,
selinux_ignore_defaults => $nexus_selinux_ignore_defaults,
require => Exec[ 'nexus-untar']
# require => Exec[ 'nexus-untar']
}

# Nexus 3 needs to have a nexus_work_dir/etc for the properties file
Expand All @@ -121,6 +160,6 @@
file{ $nexus_home:
ensure => link,
target => $nexus_home_real,
require => Exec['nexus-untar']
require => File[$nexus_home_real]
}
}
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
$pro_download_site = 'http://download.sonatype.com/nexus/professional-bundle'
$nexus_data_folder = undef
$download_folder = '/srv'
$download_provider = 'wget::fetch'
$manage_config = true
$md5sum = undef
}
6 changes: 4 additions & 2 deletions spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
{
'deploy_pro' => false,
'download_site' => 'http://download.sonatype.com/nexus/oss',
'download_provider' => 'wget::fetch',
'nexus_root' => '/srv',
'nexus_home_dir' => 'nexus',
'nexus_user' => 'nexus',
Expand Down Expand Up @@ -42,14 +43,15 @@
'command' => 'tar zxf /srv/nexus-2.11.2-01-bundle.tar.gz --directory /srv',
'creates' => '/srv/nexus-2.11.2-01',
'path' => [ '/bin', '/usr/bin' ],
'before' => 'File[/srv/nexus/2.11.2-01]'
) }

it { should contain_file('/srv/nexus-2.11.2-01').with(
'ensure' => 'directory',
'owner' => 'nexus',
'group' => 'nexus',
'recurse' => true,
'require' => 'Exec[nexus-untar]',
# 'require' => 'Exec[nexus-untar]',
) }

it { should contain_file('/srv/sonatype-work/nexus').with(
Expand All @@ -63,7 +65,7 @@
it { should contain_file('/srv/nexus').with(
'ensure' => 'link',
'target' => '/srv/nexus-2.11.2-01',
'require' => 'Exec[nexus-untar]',
'require' => 'File[/srv/nexus-2.11.2-01]',
) }

it 'should handle deploy_pro' do
Expand Down