Puppet Class: puppet_agent::install

Defined in:
manifests/install.pp

Overview

This class is called from puppet_agent for install.

Parameters:

  • package_version (String) (defaults to: 'present')

    The puppet-agent version to install.

  • install_dir (Optional) (defaults to: undef)

    The directory the puppet agent should be installed to. This is only applicable for windows operating systems.

  • install_options (Array) (defaults to: [])

    An array of additional options to pass when installing puppet-agent. Each option in the array can either be a string or a hash. Each option will automatically be quoted when passed to the install command. With Windows packages, note that file paths in an install option must use backslashes. (Since install options are passed directly to the installation command, forward slashes won’t be automatically converted like they are in ‘file` resources.) Note also that backslashes in double-quoted strings must be escaped and backslashes in single-quoted strings can be escaped.



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
105
106
107
108
109
110
# File 'manifests/install.pp', line 16

class puppet_agent::install (
  String   $package_version = 'present',
  Optional $install_dir     = undef,
  Array    $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 $facts['os']['name'] == 'Solaris' {
    class { 'puppet_agent::install::solaris':
      package_version => $package_version,
      install_options => $install_options,
    }
    contain 'puppet_agent::install::solaris'
  } elsif $facts['os']['name'] == '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 $facts['os']['family'] == '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 $facts['os']['family'] == '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 $facts['os']['name'] == '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 $facts['os']['family'] == '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${facts['os']['distro']['codename']}"
        }
        $_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 : }
  }
}