Puppet Class: nexus::package

Defined in:
manifests/package.pp

Overview

Class: nexus::package

Install the Nexus package

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::package’: }

Authors

Tom McLaughlin <tmclaughlin@hubspot.com>

Copyright 2013 Hubspot

Parameters:

  • version (Any) (defaults to: $::nexus::version)
  • revision (Any) (defaults to: $::nexus::revision)
  • deploy_pro (Any) (defaults to: $::nexus::deploy_pro)
  • download_site (Any) (defaults to: $::nexus::download_site)
  • nexus_type (Any) (defaults to: $::nexus::nexus_type)
  • nexus_root (Any) (defaults to: $::nexus::nexus_root)
  • nexus_home_dir (Any) (defaults to: $::nexus::nexus_home_dir)
  • nexus_user (Any) (defaults to: $::nexus::nexus_user)
  • nexus_group (Any) (defaults to: $::nexus::nexus_group)
  • nexus_work_dir (Any) (defaults to: $::nexus::nexus_work_dir)
  • nexus_work_dir_manage (Any) (defaults to: $::nexus::nexus_work_dir_manage)
  • nexus_work_recurse (Any) (defaults to: $::nexus::nexus_work_recurse)
  • nexus_selinux_ignore_defaults (Any) (defaults to: $::nexus::nexus_selinux_ignore_defaults)
  • download_folder (Any) (defaults to: $::nexus::download_folder)


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'manifests/package.pp', line 30

class nexus::package (
  $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,
) {

  $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,
    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']
    }
  }

  file{ $nexus_home:
    ensure  => link,
    target  => $nexus_home_real,
    require => Exec['nexus-untar']
  }
}