Puppet Class: sensu::repo::apt

Defined in:
manifests/repo/apt.pp

Summary

Adds the Sensu repo to Apt

Overview

Adds the Sensu repo to Apt



5
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
# File 'manifests/repo/apt.pp', line 5

class sensu::repo::apt {

  if defined(apt::source) {

    $ensure = $::sensu::install_repo ? {
      true    => 'present',
      default => 'absent'
    }

    if $::sensu::repo_source {
      $url = $::sensu::repo_source
    } else {
      $url = 'https://sensu.global.ssl.fastly.net/apt'
    }

    # ignoring the puppet-lint plugin because of a bug that warns on the next
    # line.
    if $::sensu::repo_release == undef { #lint:ignore:undef_in_function
      $release = $::facts['os']['distro']['codename']
    } else {
      $release = $::sensu::repo_release
    }

    apt::source { 'sensu':
      ensure   => $ensure,
      location => $url,
      release  => $release,
      repos    => $::sensu::repo,
      include  => {
        'src' => false,
      },
      key      => {
        'id'     => $::sensu::repo_key_id,
        'source' => $::sensu::repo_key_source,
      },
      before   => Package[$sensu::package::pkg_title],
      notify   => Exec['apt-update'],
    }

    exec {
      'apt-update':
        refreshonly => true,
        command     => '/usr/bin/apt-get update';
    }

    if $::sensu::enterprise {
      $se_user = $::sensu::enterprise_user
      $se_pass = $::sensu::enterprise_pass
      $se_url  = "http://${se_user}:${se_pass}@enterprise.sensuapp.com/apt"
      $include = { 'src' => false, }
      $key     = {
        'id'      => $::sensu::enterprise_repo_key_id,
        # TODO: this is not ideal, but the apt module doesn't currently support
        # HTTP auth for the source URI
        'content' => template('sensu/pubkey.gpg'),
      }

      apt::source { 'sensu-enterprise':
        ensure   => $ensure,
        location => $se_url,
        release  => 'sensu-enterprise',
        repos    => $::sensu::repo,
        include  => $include,
        key      => $key,
        before   => Package['sensu-enterprise'],
      }
    }

  } else {
    fail('This class requires puppetlabs-apt module')
  }
}