Puppet Class: telegraf::install

Defined in:
manifests/install.pp

Overview

Class: telegraf::install

Conditionally handle InfluxData’s official repos and install the necessary Telegraf package.



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

class telegraf::install {

  assert_private()

  $_operatingsystem = downcase($::operatingsystem)

  if $::telegraf::manage_repo {
    case $::osfamily {
      'Debian': {
        apt::source { 'influxdata':
          comment  => 'Mirror for InfluxData packages',
          location => "${::telegraf::repo_location}${_operatingsystem}",
          release  => $::lsbdistcodename,
          repos    => $::telegraf::repo_type,
          key      => {
            'id'     => '05CE15085FC09D18E99EFB22684A14CF2582E0C5',
            'source' => "${::telegraf::repo_location}influxdb.key",
          },
        }
        Class['apt::update'] -> Package[$::telegraf::package_name]
      }
      'RedHat': {
        if $_operatingsystem == 'amazon' {
            $_baseurl = "https://repos.influxdata.com/rhel/6/\$basearch/${::telegraf::repo_type}"
        } else {
            $_baseurl = "https://repos.influxdata.com/rhel/\$releasever/\$basearch/${::telegraf::repo_type}"
        }
        yumrepo { 'influxdata':
          name     => 'influxdata',
          descr    => "InfluxData Repository - ${::operatingsystem} \$releasever",
          enabled  => 1,
          baseurl  => $_baseurl,
          gpgkey   => "${::telegraf::repo_location}influxdb.key",
          gpgcheck => 1,
        }
        Yumrepo['influxdata'] -> Package[$::telegraf::package_name]
      }
      'windows': {
        # repo is not applicable to windows
      }
      default: {
        fail('Only RedHat, CentOS, OracleLinux, Debian, Ubuntu and Windows are supported at this time')
      }
    }
  }

  if $::osfamily == 'windows' {
    # required to install telegraf on windows
    require chocolatey

    # package install
    package { $::telegraf::package_name:
      ensure          => $::telegraf::ensure,
      provider        => chocolatey,
      source          => $::telegraf::windows_package_url,
      install_options => $::telegraf::install_options,
    }
  } else {
    ensure_packages([$::telegraf::package_name], { ensure => $::telegraf::ensure, install_options => $::telegraf::install_options })
  }

}