Puppet Class: puppet_agent::install

Defined in:
manifests/install.pp

Overview

Class puppet_agent::install

This class is called from puppet_agent for install.

Parameters

version

The puppet-agent version to install.

Parameters:

  • package_version (Any) (defaults to: 'present')
  • install_dir (Any) (defaults to: undef)
  • install_options (Any) (defaults to: [])


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
# File 'manifests/install.pp', line 10

class puppet_agent::install(
  $package_version   = 'present',
  $install_dir       = undef,
  $install_options   = [],
) {
  assert_private()

  # Solaris, MacOS, Windows platforms will require more than just a package
  # resource to install correctly. These will call to other classes that
  # define how the installations work.
  if $::operatingsystem == 'Solaris' {
    class { 'puppet_agent::install::solaris':
      package_version => $package_version,
      install_options => $install_options,
    }
    contain '::puppet_agent::install::solaris'
  } elsif $::operatingsystem == 'Darwin' {
    # Prevent re-running the script install
    if $puppet_agent::aio_upgrade_required {
      class { 'puppet_agent::install::darwin':
        package_version => $package_version,
        install_options => $install_options,
      }
      contain '::puppet_agent::install::darwin'
    }
  } elsif $::osfamily == 'windows' {
    # Prevent re-running the batch install
    if ($puppet_agent::aio_upgrade_required) or ($puppet_agent::aio_downgrade_required){
      class { 'puppet_agent::install::windows':
        install_dir     => $install_dir,
        install_options => $install_options,
      }
      contain '::puppet_agent::install::windows'
    }
  } elsif $::osfamily == 'suse' {
    # Prevent re-running the batch install
    if ($package_version =~ /^latest$|^present$/) or ($puppet_agent::aio_upgrade_required) or ($puppet_agent::aio_downgrade_required){
      class { 'puppet_agent::install::suse':
        package_version => $package_version,
        install_options => $install_options,
      }
      contain '::puppet_agent::install::suse'
    }
  } else {
    if $::operatingsystem == 'AIX' {
      # AIX installations always use RPM directly since no there isn't any default package manager for rpms
      $_package_version = $package_version
      $_install_options = concat(['--ignoreos'],$install_options)
      $_provider = 'rpm'
      $_source = "${::puppet_agent::params::local_packages_dir}/${::puppet_agent::prepare::package::package_file_name}"
    } elsif $::osfamily == 'Debian' {
      $_install_options = $install_options
      if $::puppet_agent::absolute_source {
        # absolute_source means we use dpkg on debian based platforms
        $_package_version = 'present'
        $_provider = 'dpkg'
        # The source package should have been downloaded by puppet_agent::prepare::package to the local_packages_dir
        $_source = "${::puppet_agent::params::local_packages_dir}/${::puppet_agent::prepare::package::package_file_name}"
      } else {
        # any other type of source means we use apt with no 'source' defined in the package resource below
        if $package_version =~ /^latest$|^present$/ {
          $_package_version = $package_version
        } else {
          $_package_version = "${package_version}-1${::lsbdistcodename}"
        }
        $_provider = 'apt'
        $_source = undef
      }
    } else { # RPM platforms: EL
      $_install_options = $install_options
      if $::puppet_agent::absolute_source {
        # absolute_source means we use rpm on EL based platforms
        $_package_version = $package_version
        $_provider = 'rpm'
        # The source package should have been downloaded by puppet_agent::prepare::package to the local_packages_dir
        $_source = "${::puppet_agent::params::local_packages_dir}/${::puppet_agent::prepare::package::package_file_name}"
      } else {
        # any other type of source means we use a package manager (yum) with no 'source' parameter in the
        # package resource below
        $_package_version = $package_version
        $_provider = 'yum'
        $_source = undef
      }
    }
    $_aio_package_version = $package_version.match(/^\d+\.\d+\.\d+(\.\d+)?|^latest$|^present$/)[0]
    package { $::puppet_agent::package_name:
      ensure          => $_package_version,
      install_options => $_install_options,
      provider        => $_provider,
      source          => $_source,
      notify          => Puppet_agent_end_run[$_aio_package_version],
    }
    puppet_agent_end_run { $_aio_package_version : }
  }
}