From 2e6fde6ccd8a0bb87053612d804093c46f2e5889 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Tue, 28 Nov 2017 13:40:08 +0000 Subject: [PATCH 01/14] adding OracleLinux as an options for systemd script --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index 0d65d71..8a14e85 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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 $::operatingsystem == 'OracleLinux') and versioncmp($::operatingsystemmajrelease, '7') >= 0) { file { '/lib/systemd/system/nexus.service': mode => '0644', owner => 'root', From f39e9d99649626183c9404c9288c6df39964a116 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Fri, 15 Dec 2017 13:07:31 +0000 Subject: [PATCH 02/14] bumping version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 13934a6..b6c2f21 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "hubspot-nexus", - "version": "1.7.3", + "version": "1.7.3.1", "source": "http://github.com/hubspotdevops/puppet-nexus", "author": "Tom McLaughlin ", "license": "MIT", From 1313cd0d0e5f6985d2acb5562b05d1bf459535a9 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 09:44:16 +0000 Subject: [PATCH 03/14] allow installation using packages --- manifests/init.pp | 50 ++++++++++++----- manifests/package.pp | 19 ++----- manifests/params.pp | 2 + manifests/wget.pp | 127 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 170 insertions(+), 28 deletions(-) create mode 100644 manifests/wget.pp diff --git a/manifests/init.pp b/manifests/init.pp index fd90c5b..45f81a0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -50,6 +50,8 @@ $download_folder = $nexus::params::download_folder, $manage_config = $nexus::params::manage_config, $md5sum = $nexus::params::md5sum, + $package_name = $nexus::params::package_name, + $package_install = $nexus::params::package_install, ) inherits nexus::params { include stdlib @@ -101,20 +103,40 @@ } } - 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'] + } + } + 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'] + } } if $manage_config { diff --git a/manifests/package.pp b/manifests/package.pp index 80296bc..e2e7b38 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -68,17 +68,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 => $full_version, } # NOTE: $nexus_work_dir in later releases was moved to a directory not @@ -90,7 +81,7 @@ group => $nexus_group, recurse => true, selinux_ignore_defaults => $nexus_selinux_ignore_defaults, - require => Exec[ 'nexus-untar'] + require => Package[$package_name], } @@ -103,7 +94,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 @@ -121,6 +112,6 @@ file{ $nexus_home: ensure => link, target => $nexus_home_real, - require => Exec['nexus-untar'] + require => Package[$package_name], } } diff --git a/manifests/params.pp b/manifests/params.pp index e27739f..19adcbf 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -42,4 +42,6 @@ $download_folder = '/srv' $manage_config = true $md5sum = undef + $package_install = false + $package_name = undef } diff --git a/manifests/wget.pp b/manifests/wget.pp new file mode 100644 index 0000000..ab511c5 --- /dev/null +++ b/manifests/wget.pp @@ -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 +# +# === 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'] + } +} From 835ddd501126ebb5569a706de9a88cc42dddcc61 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 10:11:56 +0000 Subject: [PATCH 04/14] bump version --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 13934a6..d7db768 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "hubspot-nexus", - "version": "1.7.3", + "version": "1.7.4", "source": "http://github.com/hubspotdevops/puppet-nexus", "author": "Tom McLaughlin ", "license": "MIT", From 64141aeb3a6fa83a68339ae7a45b2e627902f016 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 10:16:15 +0000 Subject: [PATCH 05/14] adding OracleLinux as an options for systemd script --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index 0d65d71..8a14e85 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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 $::operatingsystem == 'OracleLinux') and versioncmp($::operatingsystemmajrelease, '7') >= 0) { file { '/lib/systemd/system/nexus.service': mode => '0644', owner => 'root', From c935f222929ed41faf4451ea3cfc69130e167f18 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 10:49:17 +0000 Subject: [PATCH 06/14] check for $::osfamily == 'RedHat' --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index 8a14e85..c524eb8 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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' or $::operatingsystem == 'OracleLinux') 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', From 2cedb12484e934bbc170eb09cc9a2e84295564df Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 11:33:49 +0000 Subject: [PATCH 07/14] check for $::osfamily == 'RedHat' --- manifests/service.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/service.pp b/manifests/service.pp index 8a14e85..c524eb8 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -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' or $::operatingsystem == 'OracleLinux') 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', From e13f6d96ed8c9fa2bee0dae50a578c5f853cab1b Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 11:35:10 +0000 Subject: [PATCH 08/14] version change --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index b6c2f21..d7db768 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "hubspot-nexus", - "version": "1.7.3.1", + "version": "1.7.4", "source": "http://github.com/hubspotdevops/puppet-nexus", "author": "Tom McLaughlin ", "license": "MIT", From 0e5ef584d40f121af60143880668947afaf9697f Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 15:27:51 +0000 Subject: [PATCH 09/14] package name & version --- manifests/init.pp | 3 +++ manifests/params.pp | 1 + 2 files changed, 4 insertions(+) diff --git a/manifests/init.pp b/manifests/init.pp index 45f81a0..cc27821 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -51,6 +51,7 @@ $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 @@ -119,6 +120,8 @@ nexus_work_recurse => $nexus_work_recurse, md5sum => $md5sum, notify => Class['nexus::service'] + package_name => $package_name, + package_version => $package_version, } } else { diff --git a/manifests/params.pp b/manifests/params.pp index 19adcbf..4eadd7d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -44,4 +44,5 @@ $md5sum = undef $package_install = false $package_name = undef + $package_version = undef } From 6c00e67be5c04cd6d6b883a774c8f956a1746238 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 15:29:34 +0000 Subject: [PATCH 10/14] package name & version --- manifests/package.pp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/manifests/package.pp b/manifests/package.pp index e2e7b38..8842230 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -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}" @@ -69,7 +71,7 @@ # linked to an exec resource which won't be realized if a directory # already exists. package { $package_name: - ensure => $full_version, + ensure => $package_version, } # NOTE: $nexus_work_dir in later releases was moved to a directory not From 1209aa5752ccf25a25cfd735740c03960f65adaa Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Wed, 14 Mar 2018 16:26:59 +0000 Subject: [PATCH 11/14] mising , --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index cc27821..9d3ffdb 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -119,7 +119,7 @@ nexus_work_dir_manage => $nexus_work_dir_manage, nexus_work_recurse => $nexus_work_recurse, md5sum => $md5sum, - notify => Class['nexus::service'] + notify => Class['nexus::service'], package_name => $package_name, package_version => $package_version, } From 9d3f5803dd245ba129cda1c16c6a8cc9e72ecf30 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Thu, 15 Mar 2018 13:00:53 +0000 Subject: [PATCH 12/14] version change --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index d7db768..a43cef6 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "hubspot-nexus", - "version": "1.7.4", + "version": "1.7.5", "source": "http://github.com/hubspotdevops/puppet-nexus", "author": "Tom McLaughlin ", "license": "MIT", From 18e65805185411b7c18d64dcded7e743b5458c56 Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Fri, 16 Mar 2018 12:06:41 +0000 Subject: [PATCH 13/14] correcting anchor error --- manifests/init.pp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 9d3ffdb..5b0a1c9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -123,6 +123,8 @@ 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': @@ -140,6 +142,8 @@ md5sum => $md5sum, notify => Class['nexus::service'] } + + anchor{ 'nexus::setup': } -> Class['nexus::wget'] -> Class['nexus::config'] -> Class['nexus::Service'] -> anchor { 'nexus::done': } } if $manage_config { @@ -162,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': } } From 4803da5001f716aee1d2395d316bae3e67f2e4de Mon Sep 17 00:00:00 2001 From: Alastair Montgomery Date: Fri, 16 Mar 2018 12:29:51 +0000 Subject: [PATCH 14/14] Version number --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index a43cef6..347d166 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "hubspot-nexus", - "version": "1.7.5", + "version": "1.7.6", "source": "http://github.com/hubspotdevops/puppet-nexus", "author": "Tom McLaughlin ", "license": "MIT",