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
59 changes: 44 additions & 15 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
$download_folder = $nexus::params::download_folder,
$manage_config = $nexus::params::manage_config,
$md5sum = $nexus::params::md5sum,
$package_name = $nexus::params::package_name,
$package_version = $nexus::params::package_version,
$package_install = $nexus::params::package_install,
) inherits nexus::params {
include stdlib

Expand Down Expand Up @@ -101,20 +104,46 @@
}
}

class{ 'nexus::package':
version => $version,
revision => $revision,
deploy_pro => $deploy_pro,
download_site => $real_download_site,
nexus_root => $nexus_root,
nexus_home_dir => $nexus_home_dir,
nexus_user => $nexus_user,
nexus_group => $nexus_group,
nexus_work_dir => $real_nexus_work_dir,
nexus_work_dir_manage => $nexus_work_dir_manage,
nexus_work_recurse => $nexus_work_recurse,
md5sum => $md5sum,
notify => Class['nexus::service']

if ($package_install and $package_name != undef) {
class{ 'nexus::package':
version => $version,
revision => $revision,
deploy_pro => $deploy_pro,
download_site => $real_download_site,
nexus_root => $nexus_root,
nexus_home_dir => $nexus_home_dir,
nexus_user => $nexus_user,
nexus_group => $nexus_group,
nexus_work_dir => $real_nexus_work_dir,
nexus_work_dir_manage => $nexus_work_dir_manage,
nexus_work_recurse => $nexus_work_recurse,
md5sum => $md5sum,
notify => Class['nexus::service'],
package_name => $package_name,
package_version => $package_version,
}

anchor{ 'nexus::setup': } -> Class['nexus::package'] -> Class['nexus::config'] -> Class['nexus::Service'] -> anchor { 'nexus::done': }
}
else {
class{ 'nexus::wget':
version => $version,
revision => $revision,
deploy_pro => $deploy_pro,
download_site => $real_download_site,
nexus_root => $nexus_root,
nexus_home_dir => $nexus_home_dir,
nexus_user => $nexus_user,
nexus_group => $nexus_group,
nexus_work_dir => $real_nexus_work_dir,
nexus_work_dir_manage => $nexus_work_dir_manage,
nexus_work_recurse => $nexus_work_recurse,
md5sum => $md5sum,
notify => Class['nexus::service']
}

anchor{ 'nexus::setup': } -> Class['nexus::wget'] -> Class['nexus::config'] -> Class['nexus::Service'] -> anchor { 'nexus::done': }
}

if $manage_config {
Expand All @@ -137,5 +166,5 @@
version => $version,
}

anchor{ 'nexus::setup': } -> Class['nexus::package'] -> Class['nexus::config'] -> Class['nexus::Service'] -> anchor { 'nexus::done': }
# anchor{ 'nexus::setup': } -> Class['nexus::package'] -> Class['nexus::config'] -> Class['nexus::Service'] -> anchor { 'nexus::done': }
}
21 changes: 7 additions & 14 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
$nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults,
$download_folder = $::nexus::download_folder,
$md5sum = $::nexus::md5sum,
$package_name = $::nexus::package_name,
$package_version = $::nexus::package_version,
) {

$nexus_home = "${nexus_root}/${nexus_home_dir}"
Expand All @@ -68,17 +70,8 @@
# 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'],
package { $package_name:
ensure => $package_version,
}

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


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

# Nexus 3 needs to have a nexus_work_dir/etc for the properties file
Expand All @@ -121,6 +114,6 @@
file{ $nexus_home:
ensure => link,
target => $nexus_home_real,
require => Exec['nexus-untar']
require => Package[$package_name],
}
}
3 changes: 3 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@
$download_folder = '/srv'
$manage_config = true
$md5sum = undef
$package_install = false
$package_name = undef
$package_version = undef
}
2 changes: 1 addition & 1 deletion manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

if ($::operatingsystem == 'Debian' and versioncmp($::operatingsystemrelease, '8.0') > 0) or
($::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '15.04') > 0) or
(($::operatingsystem == 'CentOS' or $::operatingsystem == 'RedHat') and versioncmp($::operatingsystemmajrelease, '7') >= 0) {
(($::operatingsystem == 'CentOS' or $::operatingsystem == 'RedHat' or $::osfamily == 'RedHat') and versioncmp($::operatingsystemmajrelease, '7') >= 0) {
file { '/lib/systemd/system/nexus.service':
mode => '0644',
owner => 'root',
Expand Down
127 changes: 127 additions & 0 deletions manifests/wget.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# === Class: nexus::wget
#
# Install the Nexus package using wget
#
# === Parameters
#
# [*version*]
# The version to download.
#
# [*revision*]
# The revision of the archive. This is needed for the name of the
# directory the archive is extracted to. The default should suffice.
#
# [*nexus_root*]
# The root directory where the nexus application will live and tarballs
# will be downloaded to.
#
# === Examples
#
# class{ 'nexus::wget': }
#
# === Authors
#
# Tom McLaughlin <tmclaughlin@hubspot.com>
#
# === Copyright
#
# Copyright 2013 Hubspot
#
class nexus::wget (
$version = $::nexus::version,
$revision = $::nexus::revision,
$deploy_pro = $::nexus::deploy_pro,
$download_site = $::nexus::download_site,
$nexus_type = $::nexus::nexus_type,
$nexus_root = $::nexus::nexus_root,
$nexus_home_dir = $::nexus::nexus_home_dir,
$nexus_user = $::nexus::nexus_user,
$nexus_group = $::nexus::nexus_group,
$nexus_work_dir = $::nexus::nexus_work_dir,
$nexus_work_dir_manage = $::nexus::nexus_work_dir_manage,
$nexus_work_recurse = $::nexus::nexus_work_recurse,
$nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults,
$download_folder = $::nexus::download_folder,
$md5sum = $::nexus::md5sum,
) {

$nexus_home = "${nexus_root}/${nexus_home_dir}"

$full_version = "${version}-${revision}"

if ($deploy_pro) {
$bundle_type = '-professional'
} else {
$bundle_type = ''
}

$nexus_archive = "nexus${bundle_type}-${full_version}-${nexus_type}.tar.gz"
$download_url = "${download_site}/${nexus_archive}"
$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'],
}

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

# NOTE: $nexus_work_dir in later releases was moved to a directory not
# under the application. This is why we do not make recursing optional
# for this resource but do for $nexus_work_dir.
file{ $nexus_home_real:
ensure => directory,
owner => $nexus_user,
group => $nexus_group,
recurse => true,
selinux_ignore_defaults => $nexus_selinux_ignore_defaults,
require => Exec[ 'nexus-untar']
}


# I have an EBS volume for $nexus_work_dir and mounting code in our tree
# creates this and results in a duplicate resource. -tmclaughlin
if $nexus_work_dir_manage == true {
file{ $nexus_work_dir:
ensure => directory,
owner => $nexus_user,
group => $nexus_group,
recurse => $nexus_work_recurse,
selinux_ignore_defaults => $nexus_selinux_ignore_defaults,
require => Exec[ 'nexus-untar']
}

# Nexus 3 needs to have a nexus_work_dir/etc for the properties file
if $version !~ /\d.*/ or versioncmp($version, '3.1.0') >= 0 {
file { "${nexus_work_dir}/etc":
ensure => directory,
owner => $nexus_user,
group => $nexus_group,
recurse => $nexus_work_recurse,
selinux_ignore_defaults => $nexus_selinux_ignore_defaults,
}
}
}

file{ $nexus_home:
ensure => link,
target => $nexus_home_real,
require => Exec['nexus-untar']
}
}
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hubspot-nexus",
"version": "1.7.3",
"version": "1.7.6",
"source": "http://github.com/hubspotdevops/puppet-nexus",
"author": "Tom McLaughlin <tmclaughlin@hubspot.com>",
"license": "MIT",
Expand Down