diff --git a/manifests/init.pp b/manifests/init.pp index 478f84b..0366d4c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,113 +1,117 @@ # == Class: varnish # # Configure Varnish proxy cache # # === Parameters # # [*addrepo*] # Whether to add the official Varnish repos # [*secret*] # Varnish secret (used by varnishadm etc). # Optional; will be autogenerated if not specified # [*vcl_conf*] # Location of Varnish config file template # [*listen*] # IP address for HTTP to listen on # [*listen_port*] # Port to listen on for HTTP requests # [*admin_listen*] # IP address for admin requests - defaults to 127.0.0.1 # [*admin_port*] # Port for Varnish admin to listen on # [*min_threads*] # Varnish minimum thread pool size # [*max_threads*] # Varnish maximum thread pool size # [*thread_timeout*] # Thread timeout # [*storage_type*] # Whether to use malloc (RAM only) or file storage for cache # [*storage_size*] # Size of cache # [*storage_additional*] # Hash of additional storage backends containing strings in the varnish format (passed to -s) # [*varnish_version*] # Major Varnish version to use # [*vcl_reload*] # Script to use to load new Varnish config # [*package_ensure*] # Ensure specific package version for Varnish, eg 3.0.5-1.el6 # [*runtime_params*] # Hash of key:value runtime parameters # class varnish ( Hash $runtime_params = {}, Boolean $addrepo = true, String $admin_listen = '127.0.0.1', Integer $admin_port = 6082, Variant[String,Array] $listen = '0.0.0.0', Integer $listen_port = 6081, Optional[String] $secret = undef, Stdlib::AbsolutePath $secret_file = '/etc/varnish/secret', Stdlib::AbsolutePath $vcl_conf = '/etc/varnish/default.vcl', Enum['file','malloc'] $storage_type = 'file', Stdlib::AbsolutePath $storage_file = '/var/lib/varnish/varnish_storage.bin', String $storage_size = '1G', Array $storage_additional = [], Integer $min_threads = 50, Integer $max_threads = 1000, Integer $thread_timeout = 120, - Pattern[/^[3-6]\.[0-9]/] $varnish_version = '4.1', + Pattern[/^[3-6]\.[0-9](lts)?/] $varnish_version = '4.1', Optional[String] $instance_name = undef, String $package_ensure = 'present', String $package_name = 'varnish', String $service_name = 'varnish', Optional[String] $vcl_reload_cmd = undef, String $vcl_reload_path = $::path, ) { if $package_ensure == 'present' { $version_major = regsubst($varnish_version, '^(\d+)\.(\d+).*$', '\1') $version_minor = regsubst($varnish_version, '^(\d+)\.(\d+).*$', '\2') $version_full = $varnish_version } else { $version_major = regsubst($package_ensure, '^(\d+)\.(\d+).*$', '\1') $version_minor = regsubst($package_ensure, '^(\d+)\.(\d+).*$', '\2') $version_full = "${version_major}.${version_minor}" if $varnish_version != "${version_major}.${version_minor}" { fail("Version mismatch, varnish_version is ${varnish_version}, but package_ensure is ${version_full}") } } + $version_lts = $varnish_version ? { + /lts$/ => 'lts', + default => '', + } include ::varnish::params if $vcl_reload_cmd == undef { $vcl_reload = $::varnish::params::vcl_reload } else { $vcl_reload = $vcl_reload_cmd } if $addrepo { class { '::varnish::repo': before => Class['::varnish::install'], } } include ::varnish::install class { '::varnish::secret': secret => $secret, require => Class['::varnish::install'], } class { '::varnish::config': require => Class['::varnish::secret'], notify => Class['::varnish::service'], } class { '::varnish::service': require => Class['::varnish::config'], } } diff --git a/manifests/repo.pp b/manifests/repo.pp index d777d5b..58bdab5 100644 --- a/manifests/repo.pp +++ b/manifests/repo.pp @@ -1,101 +1,102 @@ # Add the Varnish repo class varnish::repo { - $ver = "${::varnish::version_major}${::varnish::version_minor}" + $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.') } } $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': { if $ver == '30' and $::lsbdistcodename == 'xenial' { fail('Varnish 3 from Packagecloud is not supported on Ubuntu 16.04 (Xenial)') } if $ver == '50' { if $::lsbdistcodename == 'wheezy' { fail('Varnish 5.0 from Packagecloud is not supported on Debian 7 (Wheezy)') } elsif $::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.') } } ensure_packages('apt-transport-https') $os_lower = downcase($::operatingsystem) $package_require = Exec['apt_update'] - $gpg_key_id = "${::varnish::version_major}.${::varnish::version_minor}" ? { - '6.1' => '4A066C99B76A0F55A40E3E1E387EF1F5742D76CC', - '6.0' => '7C5B46721AF00FD57E68E6E8D2605BF74E8B9DBA', - '5.2' => '91CFD5635A1A5FAC0662BEDD2E9BA3FE86BE909D', - '5.1' => '54DC32329C37703D8B2819E6414C46826B880524', - '5.0' => '1487779B0E6C440214F07945632B6ED0FF6A1C76', - '4.1' => '9C96F9CA0DC3F4EA78FF332834BF6E8ECBF5C49E', - '4.0' => 'B7B16293AE0CC24216E9A83DD4E49AD8DE3FFEA4', - '3.0' => '246BE381150865E2DC8C6B01FC1318ACEE2C594C', + $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}", + 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}") } } }