Puppet Class: varnish::repo

Defined in:
manifests/repo.pp

Overview

Add the Varnish repo



2
3
4
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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'manifests/repo.pp', line 2

class varnish::repo {

  $ver = "${::varnish::version_major}${::varnish::version_minor}${::varnish::version_lts}"

  case $::osfamily {
    'RedHat': {

      if $ver == '50' {
        if $::operatingsystemmajrelease == '6'  {
          fail('Varnish 5.0 from Packagecloud is not supported on RHEL/CentOS 6')
        } elsif $::operatingsystemmajrelease == '7' {
          # https://github.com/varnishcache/pkg-varnish-cache/issues/42
          fail('Varnish 5.0 on RHEL/CentOS 7 has a known packaging bug in the varnish_reload_vcl script, please use 5.1 instead. If the bug has been fixed, please submit a pull request to remove this message.')
        }
      }

      if $::varnish::version_major == '6' and $::operatingsystemmajrelease == '6' {
        fail('Varnish 6.0 and above from Packagecloud is not supported on RHEL/CentOS 6')
      }

      $package_require = undef

      # Varnish 4 and above need EPEL for jemalloc
      if $::varnish::version_major != '3' {
        include ::epel
        Yumrepo['varnish-cache','varnish-cache-source'] {
          require => Yumrepo['epel'],
        }
      }

      yumrepo { 'varnish-cache':
        descr           => "varnishcache_varnish${ver}",
        baseurl         => "https://packagecloud.io/varnishcache/varnish${ver}/el/${::operatingsystemmajrelease}/\$basearch",
        gpgkey          => "https://packagecloud.io/varnishcache/varnish${ver}/gpgkey",
        metadata_expire => '300',
        repo_gpgcheck   => '1',
        gpgcheck        => '0',
        sslverify       => '1',
        sslcacert       => '/etc/pki/tls/certs/ca-bundle.crt',
      }

      yumrepo { 'varnish-cache-source':
        descr           => "varnishcache_varnish${ver}-source",
        baseurl         => "https://packagecloud.io/varnishcache/varnish${ver}/el/${::operatingsystemmajrelease}/SRPMS",
        gpgkey          => "https://packagecloud.io/varnishcache/varnish${ver}/gpgkey",
        metadata_expire => '300',
        repo_gpgcheck   => '1',
        gpgcheck        => '0',
        sslverify       => '1',
        sslcacert       => '/etc/pki/tls/certs/ca-bundle.crt',
      }
    }


    'Debian': {
      case $::operatingsystem {
        'Debian': {
          if $ver == '50' and $::lsbdistcodename == 'wheezy' {
            fail('Varnish 5.0 from Packagecloud is not supported on Debian 7 (Wheezy)')
          }

          if $::varnish::version_major == '6' and $::lsbdistcodename != 'stretch' {
            fail('Varnish 6.0 and above is only supported on Debian 9 (Stretch)')
          }
        }

        'Ubuntu': {
          if $ver == '30' and versioncmp($::operatingsystemmajrelease,'16.04') >= 0 {
            fail('Varnish 3 from Packagecloud is not supported after Ubuntu 14.04 (Trusty)')
          }

          if $ver == '50' and $::lsbdistcodename == 'trusty' {
            fail('Varnish 5.0 has a known packaging bug in the reload-vcl script, please use 5.1 instead. If the bug has been fixed, please submit a pull request to remove this message.')
          }

          if $::varnish::version_major == '6' and versioncmp($::operatingsystemmajrelease,'16.04') == -1 {
            fail('Varnish 6.0 and above is only supported on Ubuntu 16.04 (Xenial) and newer')
          }
        }

        default: {
          fail("Unsupported Debian OS: ${::operatingsystem}")
        }
      }

      ensure_packages('apt-transport-https')

      $os_lower        = downcase($::operatingsystem)
      $package_require = Exec['apt_update']
      $gpg_key_id      = "${::varnish::version_major}.${::varnish::version_minor}${::varnish::version_lts}" ? {
        '6.1'    => '4A066C99B76A0F55A40E3E1E387EF1F5742D76CC',
        '6.0lts' => '48D81A24CB0456F5D59431D94CFCFD6BA750EDCD',
        '6.0'    => '7C5B46721AF00FD57E68E6E8D2605BF74E8B9DBA',
        '5.2'    => '91CFD5635A1A5FAC0662BEDD2E9BA3FE86BE909D',
        '5.1'    => '54DC32329C37703D8B2819E6414C46826B880524',
        '5.0'    => '1487779B0E6C440214F07945632B6ED0FF6A1C76',
        '4.1'    => '9C96F9CA0DC3F4EA78FF332834BF6E8ECBF5C49E',
        '4.0'    => 'B7B16293AE0CC24216E9A83DD4E49AD8DE3FFEA4',
        '3.0'    => '246BE381150865E2DC8C6B01FC1318ACEE2C594C',
      }

      ::apt::source { 'varnish-cache':
        comment  => "Apt source for Varnish ${::varnish::version_major}.${::varnish::version_minor}${::varnish::version_lts}",
        location => "https://packagecloud.io/varnishcache/varnish${ver}/${os_lower}/",
        repos    => 'main',
        require  => Package['apt-transport-https'],
        key      => {
          source => "https://packagecloud.io/varnishcache/varnish${ver}/gpgkey",
          id     => $gpg_key_id,
        },
        include  => {
          'deb' => true,
          'src' => true,
        },
      }
    }

    default: {
      fail("Unsupported repo osfamily: ${::osfamily}")
    }
  }
}