Puppet Class: datadog_agent::redhat

Inherits:
datadog_agent::params
Defined in:
manifests/redhat.pp

Overview

Parameters:

  • agent_major_version (Integer) (defaults to: $datadog_agent::params::default_agent_major_version)
  • agent_repo_uri (Optional[String]) (defaults to: undef)
  • manage_repo (Boolean) (defaults to: true)
  • agent_version (String) (defaults to: $datadog_agent::params::agent_version)
  • agent_flavor (String) (defaults to: $datadog_agent::params::package_name)
  • rpm_repo_gpgcheck (Optional[Boolean]) (defaults to: undef)


6
7
8
9
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
# File 'manifests/redhat.pp', line 6

class datadog_agent::redhat(
  Integer $agent_major_version = $datadog_agent::params::default_agent_major_version,
  Optional[String] $agent_repo_uri = undef,
  Boolean $manage_repo = true,
  String $agent_version = $datadog_agent::params::agent_version,
  String $agent_flavor = $datadog_agent::params::package_name,
  Optional[Boolean] $rpm_repo_gpgcheck = undef,
) inherits datadog_agent::params {

  if $manage_repo {

    $keys = [
        'https://keys.datadoghq.com/DATADOG_RPM_KEY_CURRENT.public',
        'https://keys.datadoghq.com/DATADOG_RPM_KEY_E09422B3.public',
        'https://keys.datadoghq.com/DATADOG_RPM_KEY_FD4BF915.public',
        'https://keys.datadoghq.com/DATADOG_RPM_KEY.public',
    ]
    if ($rpm_repo_gpgcheck != undef) {
      $repo_gpgcheck = $rpm_repo_gpgcheck
    } else {
      if ($agent_repo_uri == undef) and ($agent_major_version > 5) {
        case $::operatingsystem {
          'RedHat', 'CentOS', 'OracleLinux': {
            # disable repo_gpgcheck on 8.1 because of https://bugzilla.redhat.com/show_bug.cgi?id=1792506
            if $::operatingsystemrelease =~ /^8.1/ {
              $repo_gpgcheck = false
            } else {
              $repo_gpgcheck = true
            }
          }
          default: {
            $repo_gpgcheck = true
          }
        }
      } else {
        $repo_gpgcheck = false
      }

    }

    case $agent_major_version {
      5 : {
        $defaulturl = "https://yum.datadoghq.com/rpm/${::architecture}/"
        $gpgkeys = $keys
      }
      6 : {
        $defaulturl = "https://yum.datadoghq.com/stable/6/${::architecture}/"
        $gpgkeys = $keys
      }
      7 : {
        $defaulturl = "https://yum.datadoghq.com/stable/7/${::architecture}/"
        $gpgkeys = $keys[0,-2]
      }
      default: { fail('invalid agent_major_version') }
    }

    if ($agent_repo_uri != undef) {
      $baseurl = $agent_repo_uri
    } else {
      $baseurl = $defaulturl
    }

    yumrepo { 'datadog-beta':
      ensure => absent,
    }

    yumrepo {'datadog5':
      ensure   => absent,
    }

    yumrepo {'datadog6':
      ensure   => absent,
    }

    yumrepo {'datadog':
      enabled       => 1,
      gpgcheck      => 1,
      gpgkey        => join($gpgkeys, "\n       "),
      repo_gpgcheck => $repo_gpgcheck,
      descr         => 'Datadog, Inc.',
      baseurl       => $baseurl,
    }

    package { $agent_flavor:
      ensure  => $agent_version,
      require => Yumrepo['datadog'],
    }
  } else {
    package { $agent_flavor:
      ensure  => $agent_version,
    }
  }
}