Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Ubuntu 16.04 support #406

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
792 changes: 523 additions & 269 deletions REFERENCE.md

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
Optional[String[1]] $notify_keyspace_events = undef,
Boolean $notify_service = true,
Boolean $managed_by_cluster_manager = false,
String[1] $minimum_version = $redis::params::minimum_version,
String[1] $package_ensure = 'present',
String[1] $package_name = $redis::params::package_name,
Stdlib::Absolutepath $pid_file = $redis::params::pid_file,
Expand Down Expand Up @@ -332,19 +331,6 @@
Integer[0] $cluster_migration_barrier = 1,
Hash[String[1], Hash] $instances = {},
) inherits redis::params {
if $package_ensure =~ /^([0-9]+:)?[0-9]+\.[0-9]/ {
if ':' in $package_ensure {
$_redis_version_real = split($package_ensure, ':')
$redis_version_real = $_redis_version_real[1]
} else {
$redis_version_real = $package_ensure
}
} else {
$redis_version_real = pick(getvar('redis_server_version'), $minimum_version)
}

$supports_protected_mode = !$redis_version_real or versioncmp($redis_version_real, '3.2.0') >= 0

contain redis::preinstall
contain redis::install
contain redis::config
Expand Down
1 change: 0 additions & 1 deletion manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,6 @@
}

$bind_arr = [$bind].flatten
$supports_protected_mode = $redis::supports_protected_mode

file { $redis_file_name_orig:
ensure => file,
Expand Down
33 changes: 1 addition & 32 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,14 @@
$sentinel_package_name = 'redis-sentinel'
$sentinel_log_file = '/var/log/redis/redis-sentinel.log'
$sentinel_working_dir = '/var/lib/redis'
$sentinel_protected_mode = true

case $facts['os']['name'] {
'Ubuntu': {
$config_group = 'redis'
$minimum_version = $facts['os']['release']['major'] ? {
'16.04' => '3.0.5',
'18.04' => '4.0.9',
default => '5.0.7',
}
$sentinel_pid_file = $facts['os']['release']['major'] ? {
'16.04' => '/var/run/redis/redis-sentinel.pid',
default => '/var/run/sentinel/redis-sentinel.pid',
}
$sentinel_pid_file = '/var/run/sentinel/redis-sentinel.pid'
}
default: {
$config_group = 'root'
$minimum_version = '3.2.5'
if versioncmp($facts['os']['release']['major'], '10') >= 0 {
$sentinel_pid_file = '/run/sentinel/redis-sentinel.pid'
} else {
Expand All @@ -63,7 +53,6 @@

$sentinel_daemonize = false
$sentinel_working_dir = '/tmp'
$sentinel_protected_mode = true

$scl = $redis::globals::scl
if $scl {
Expand All @@ -83,11 +72,6 @@
$sentinel_package_name = $package_name
$sentinel_pid_file = "/var/opt/rh/${scl}/run/redis-sentinel.pid"
$sentinel_log_file = "/var/opt/rh/${scl}/log/redis/sentinel.log"

$minimum_version = $scl ? {
'rh-redis32' => '3.2.13',
default => '5.0.5',
}
} else {
$config_dir = '/etc/redis'
$config_file = '/etc/redis.conf'
Expand All @@ -105,9 +89,6 @@
$sentinel_package_name = 'redis'
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$sentinel_log_file = '/var/log/redis/sentinel.log'

# EPEL 7 and newer have 3.2 so we can assume all EL is 3.2+
$minimum_version = '3.2.12'
}
}

Expand Down Expand Up @@ -137,10 +118,6 @@
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$sentinel_log_file = '/var/log/redis/sentinel.log'
$sentinel_working_dir = '/tmp'
$sentinel_protected_mode = true

# pkg version
$minimum_version = '3.2.4'
}

'Suse': {
Expand Down Expand Up @@ -168,10 +145,6 @@
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$sentinel_log_file = '/var/log/redis/sentinel.log'
$sentinel_working_dir = '/tmp'
$sentinel_protected_mode = true

# suse package version
$minimum_version = '3.0.5'
}

'Archlinux': {
Expand Down Expand Up @@ -200,10 +173,6 @@
$sentinel_pid_file = '/var/run/redis/redis-sentinel.pid'
$sentinel_log_file = '/var/log/redis/sentinel.log'
$sentinel_working_dir = '/tmp'
$sentinel_protected_mode = true

# pkg version
$minimum_version = '3.2.4'
}
default: {
fail "Operating system ${facts['os']['name']} is not supported yet."
Expand Down
3 changes: 1 addition & 2 deletions manifests/sentinel.pp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
Stdlib::Filemode $config_file_mode = '0644',
String[1] $conf_template = 'redis/redis-sentinel.conf.erb',
Boolean $daemonize = $redis::params::sentinel_daemonize,
Boolean $protected_mode = $redis::params::sentinel_protected_mode,
Boolean $protected_mode = true,
Integer[1] $down_after = 30000,
Integer[1] $failover_timeout = 180000,
Redis::LogLevel $log_level = 'notice',
Expand Down Expand Up @@ -145,7 +145,6 @@
Package[$package_name] -> File[$config_file_orig]

$sentinel_bind_arr = delete_undef_values([$sentinel_bind].flatten)
$supports_protected_mode = $redis::supports_protected_mode

file { $config_file_orig:
ensure => file,
Expand Down
1 change: 0 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"16.04",
"18.04",
"20.04"
]
Expand Down
15 changes: 7 additions & 8 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,23 @@

let(:pidfile) do
if facts[:operatingsystem] == 'Ubuntu'
facts[:operatingsystemmajrelease] == '16.04' ? '/var/run/redis/redis-sentinel.pid' : '/var/run/sentinel/redis-sentinel.pid'
'/var/run/sentinel/redis-sentinel.pid'
elsif facts[:operatingsystem] == 'Debian'
facts[:operatingsystemmajrelease] == '9' ? '/var/run/redis/redis-sentinel.pid' : '/run/sentinel/redis-sentinel.pid'
else
'/var/run/redis/redis-sentinel.pid'
end
end

let(:protected_mode) do
facts[:operatingsystem] != 'Ubuntu' || facts[:operatingsystemmajrelease] != '16.04'
end

describe 'without parameters' do
let(:expected_content) do
<<CONFIG
port 26379
dir #{facts[:osfamily] == 'Debian' ? '/var/lib/redis' : '/tmp'}
daemonize #{facts[:osfamily] == 'RedHat' ? 'no' : 'yes'}
pidfile #{pidfile}
#{protected_mode ? "protected-mode yes\n" : ''}
protected-mode yes

sentinel monitor mymaster 127.0.0.1 6379 2
sentinel down-after-milliseconds mymaster 30000
sentinel parallel-syncs mymaster 1
Expand Down Expand Up @@ -97,7 +94,8 @@
dir /tmp/redis
daemonize #{facts[:osfamily] == 'RedHat' ? 'no' : 'yes'}
pidfile #{pidfile}
#{protected_mode ? "protected-mode no\n" : ''}
protected-mode no

sentinel monitor cow 127.0.0.1 6379 2
sentinel down-after-milliseconds cow 6000
sentinel parallel-syncs cow 1
Expand Down Expand Up @@ -138,7 +136,8 @@
dir /tmp/redis
daemonize #{facts[:osfamily] == 'RedHat' ? 'no' : 'yes'}
pidfile #{pidfile}
#{protected_mode ? "protected-mode yes\n" : ''}
protected-mode yes

sentinel monitor cow 127.0.0.1 6379 2
sentinel down-after-milliseconds cow 6000
sentinel parallel-syncs cow 1
Expand Down
42 changes: 3 additions & 39 deletions spec/classes/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@
context "on #{os}" do
let(:facts) { facts }

if facts[:operatingsystem] == 'Ubuntu' && facts[:operatingsystemmajrelease] == '16.04'
let(:systemd) { '' }
let(:servicetype) { 'forking' }
else
let(:systemd) { ' --supervised systemd' }
let(:servicetype) { 'notify' }
end

describe 'without parameters' do
it { is_expected.to compile.with_all_deps }
it { is_expected.to create_class('redis') }
Expand Down Expand Up @@ -702,13 +694,7 @@ class { 'redis::globals':
}
end

it do
if facts[:operatingsystem] == 'Ubuntu' && facts[:operatingsystemmajrelease] == '16.04'
is_expected.not_to contain_file(config_file_orig).with_content(%r{protected-mode})
else
is_expected.to contain_file(config_file_orig).with_content(%r{^protected-mode no$})
end
end
it { is_expected.to contain_file(config_file_orig).with_content(%r{^protected-mode no$}) }
end

describe 'with parameter hll_sparse_max_bytes' do
Expand Down Expand Up @@ -1375,8 +1361,8 @@ class { 'redis::globals':
|[Service]
|RuntimeDirectory=redis
|RuntimeDirectoryMode=2755
|Type=#{servicetype}
|ExecStart=/usr/bin/redis-server #{config_file}#{systemd}
|Type=notify
|ExecStart=/usr/bin/redis-server #{config_file} --supervised systemd
|ExecStop=/usr/bin/redis-cli -p 6379 shutdown
|Restart=always
|User=redis
Expand All @@ -1400,28 +1386,6 @@ class { 'redis::globals':

it { is_expected.not_to contain_systemd__unit_file("#{service_name}.service") }
end

context 'when $::redis_server_version fact is not present' do
let(:facts) { super().merge(redis_server_version: nil) }

context 'when package_ensure is version (3.2.1)' do
let(:params) { { package_ensure: '3.2.1' } }

it { is_expected.to contain_file(config_file_orig).with_content(%r{^protected-mode}) }
end

context 'when package_ensure is a newer version(4.0-rc3) (older features enabled)' do
let(:params) { { package_ensure: '4.0-rc3' } }

it { is_expected.to contain_file(config_file_orig).with_content(%r{^protected-mode}) }
end
end

context 'when $::redis_server_version fact is present but a newer version (older features enabled)' do
let(:facts) { super().merge(redis_server_version: '3.2.1') }

it { is_expected.to contain_file(config_file_orig).with_content(%r{^protected-mode}) }
end
end
end
end
2 changes: 0 additions & 2 deletions templates/redis-sentinel.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ port <%= @sentinel_port %>
dir <%= @working_dir %>
daemonize <%= @daemonize ? 'yes' : 'no' %>
pidfile <%= @pid_file %>
<% if @supports_protected_mode -%>
protected-mode <%= @protected_mode ? 'yes' : 'no' %>
<% end -%>

sentinel monitor <%= @master_name %> <%= @redis_host %> <%= @redis_port %> <%= @quorum %>
sentinel down-after-milliseconds <%= @master_name %> <%= @down_after %>
Expand Down
2 changes: 0 additions & 2 deletions templates/redis.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ daemonize <% if @daemonize -%>yes<% else -%>no<% end -%>
# default. You can specify a custom pid file location here.
pidfile <%= @pid_file %>

<% if @supports_protected_mode -%>
# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
Expand All @@ -40,7 +39,6 @@ pidfile <%= @pid_file %>
# are explicitly listed using the "bind" directive.
protected-mode <%= @protected_mode ? 'yes' : 'no' %>

<% end -%>
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port <%= @port %>
Expand Down
6 changes: 0 additions & 6 deletions templates/service_templates/redis.service.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ Wants=network-online.target
[Service]
RuntimeDirectory=redis
RuntimeDirectoryMode=2755
<%# Redis on Xenial is too old for systemd integration -%>
<% if @facts['os']['name'] == 'Ubuntu' and @facts['os']['release']['major'] == '16.04' -%>
Type=forking
ExecStart=/usr/bin/redis-server <%= @redis_file_name %>
<% else -%>
Type=notify
ExecStart=<%= scope['redis::params::bin_path'] %>/redis-server <%= @redis_file_name %> --supervised systemd
<% end -%>
ExecStop=<%= scope['redis::params::bin_path'] %>/redis-cli -p <%= @port %> shutdown
Restart=always
User=<%= @service_user %>
Expand Down