2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ If you have Ruby 2.x or want a specific version of Puppet,
you must set an environment variable such as:

```sh
export PUPPET_GEM_VERSION="~> 5.5.6"
export PUPPET_GEM_VERSION="~> 6.1.0"
```

You can install all needed gems for spec tests into the modules directory by
Expand Down
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '5.2.0'
modulesync_config_version: '5.3.0'
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
Each new release typically also includes the latest modulesync defaults.
These should not affect the functionality of the module.

## [v8.6.0](https://github.com/voxpupuli/puppet-redis/tree/v8.6.0) (2022-12-05)

[Full Changelog](https://github.com/voxpupuli/puppet-redis/compare/v8.5.0...v8.6.0)

**Implemented enhancements:**

- Add support for managing Redis APT repo [\#456](https://github.com/voxpupuli/puppet-redis/pull/456) ([zaben903](https://github.com/zaben903))

## [v8.5.0](https://github.com/voxpupuli/puppet-redis/tree/v8.5.0) (2022-10-28)

[Full Changelog](https://github.com/voxpupuli/puppet-redis/compare/v8.4.0...v8.5.0)
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

source ENV['GEM_SOURCE'] || "https://rubygems.org"
source ENV['GEM_SOURCE'] || 'https://rubygems.org'

group :test do
gem 'voxpupuli-test', '~> 5.0', :require => false
gem 'voxpupuli-test', '~> 5.4', :require => false
gem 'coveralls', :require => false
gem 'simplecov-console', :require => false
gem 'puppet_metadata', '~> 1.0', :require => false
Expand Down
54 changes: 54 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ The following parameters are available in the `redis` class:
* [`port`](#-redis--port)
* [`protected_mode`](#-redis--protected_mode)
* [`ppa_repo`](#-redis--ppa_repo)
* [`redis_apt_repo`](#-redis--redis_apt_repo)
* [`apt_location`](#-redis--apt_location)
* [`apt_repos`](#-redis--apt_repos)
* [`apt_release`](#-redis--apt_release)
* [`apt_key_id`](#-redis--apt_key_id)
* [`apt_key_server`](#-redis--apt_key_server)
* [`rdbcompression`](#-redis--rdbcompression)
* [`rename_commands`](#-redis--rename_commands)
* [`repl_backlog_size`](#-redis--repl_backlog_size)
Expand Down Expand Up @@ -649,6 +655,54 @@ Specify upstream (Ubuntu) PPA entry.

Default value: `undef`

##### <a name="-redis--redis_apt_repo"></a>`redis_apt_repo`

Data type: `Boolean`

If you want to use the redis apt repository.

Default value: `false`

##### <a name="-redis--apt_location"></a>`apt_location`

Data type: `Stdlib::HTTPSUrl`

Specify the URL of the apt repository.

Default value: `'https://packages.redis.io/deb/'`

##### <a name="-redis--apt_repos"></a>`apt_repos`

Data type: `String[1]`

Specify the repository to use for apt. Defaults to 'main'.

Default value: `'main'`

##### <a name="-redis--apt_release"></a>`apt_release`

Data type: `Optional[String]`

Specify the os codename.

Default value: `undef`

##### <a name="-redis--apt_key_id"></a>`apt_key_id`

Data type: `String[1]`

Specify the PGP key id to use for apt.

Default value: `'54318FA4052D1E61A6B6F7BB5F4349D6BF53AA0C'`

##### <a name="-redis--apt_key_server"></a>`apt_key_server`

Data type: `String[1]`

Specify the PGP key server to use for apt.

Default value: `'hkp://keyserver.ubuntu.com/'`

##### <a name="-redis--rdbcompression"></a>`rdbcompression`

Data type: `Boolean`
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ begin
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file.\nEach new release typically also includes the latest modulesync defaults.\nThese should not affect the functionality of the module."
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix modulesync skip-changelog}
config.user = 'voxpupuli'
config.project = metadata.metadata['name']
config.project = 'puppet-redis'
end

# Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
Expand Down
18 changes: 18 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@
# Whether protected mode is enabled or not. Only applicable when no bind is set.
# @param ppa_repo
# Specify upstream (Ubuntu) PPA entry.
# @param redis_apt_repo
# If you want to use the redis apt repository.
# @param apt_location
# Specify the URL of the apt repository.
# @param apt_repos
# Specify the repository to use for apt. Defaults to 'main'.
# @param apt_release
# Specify the os codename.
# @param apt_key_id
# Specify the PGP key id to use for apt.
# @param apt_key_server
# Specify the PGP key server to use for apt.
# @param rdbcompression
# Enable/disable compression of string objects using LZF when dumping.
# @param rename_commands
Expand Down Expand Up @@ -363,6 +375,12 @@
Stdlib::Port $port = 6379,
Boolean $protected_mode = true,
Optional[String] $ppa_repo = undef,
Boolean $redis_apt_repo = false,
Stdlib::HTTPSUrl $apt_location = 'https://packages.redis.io/deb/',
String[1] $apt_repos = 'main',
Optional[String] $apt_release = undef,
String[1] $apt_key_id = '54318FA4052D1E61A6B6F7BB5F4349D6BF53AA0C',
String[1] $apt_key_server = 'hkp://keyserver.ubuntu.com/',
Boolean $rdbcompression = true,
Hash[String,String] $rename_commands = {},
String[1] $repl_backlog_size = '1mb',
Expand Down
13 changes: 12 additions & 1 deletion manifests/preinstall.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@
}
} elsif $facts['os']['name'] == 'Ubuntu' and $redis::ppa_repo {
contain 'apt'
apt::ppa { $redis::ppa_repo:
apt::ppa { $redis::ppa_repo: }
} elsif $facts['os']['family'] == 'Debian' and $redis::redis_apt_repo {
include 'apt'

apt::source { 'redis':
location => $redis::apt_location,
release => $redis::apt_release,
repos => $redis::apt_repos,
key => {
id => $redis::apt_key_id,
server => $redis::apt_key_server,
},
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppet-redis",
"version": "8.5.0",
"version": "8.6.0",
"author": "Vox Pupuli",
"summary": "Redis module",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class { '::redis':
default_install => false,
service_enable => false,
service_ensure => 'stopped',
protected_mode => false,
bind => [],
}
$listening_ports.each |$port| {
Expand Down
13 changes: 13 additions & 0 deletions spec/acceptance/suites/default/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,17 @@
its(:stdout) { is_expected.to match %r{PONG} }
end
end

it 'runs successfully when using Redis apt repository', if: (fact('os.family') == 'Debian') do
pp = <<-EOS
class { '::redis':
manage_repo => true,
redis_apt_repo => true,
}
EOS

# Apply twice to ensure no errors the second time.
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
3 changes: 3 additions & 0 deletions spec/classes/redis_sentinel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
port 26379
dir #{facts[:os]['family'] == 'Debian' ? '/var/lib/redis' : '/tmp'}
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
supervised auto
pidfile #{pidfile}
protected-mode yes
Expand Down Expand Up @@ -124,6 +125,7 @@ class { 'redis':
tls-port 26380
dir /tmp/redis
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
supervised auto
pidfile #{pidfile}
protected-mode no
Expand Down Expand Up @@ -177,6 +179,7 @@ class { 'redis':
port 26379
dir /tmp/redis
daemonize #{facts[:os]['family'] == 'RedHat' ? 'no' : 'yes'}
supervised auto
pidfile #{pidfile}
protected-mode yes
Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

require 'voxpupuli/test/spec_helper'

add_mocked_facts!

if File.exist?(File.join(__dir__, 'default_module_facts.yml'))
facts = YAML.safe_load(File.read(File.join(__dir__, 'default_module_facts.yml')))
facts&.each do |name, value|
Expand Down
10 changes: 10 additions & 0 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@
# https://tickets.puppetlabs.com/browse/MODULES-11275
host.install_package('puppet-bolt')
end

if fact_on(host, 'osfamily') == 'Debian'
# APT required for Debian based systems where `$redis::manage_repo` is `true`
install_module_from_forge_on(host, 'puppetlabs/apt', '>= 9.0.0')

if Gem::Version.new(fact_on(host, 'facterversion')) < Gem::Version.new('4.0.0')
# Install prerequisites where Facter 3 is used
host.install_package('lsb-release')
end
end
end
1 change: 1 addition & 0 deletions templates/redis-sentinel.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ tls-port <%= @sentinel_tls_port %>
<% end -%>
dir <%= @working_dir %>
daemonize <%= @daemonize ? 'yes' : 'no' %>
supervised auto
pidfile <%= @pid_file %>
protected-mode <%= @protected_mode ? 'yes' : 'no' %>
Expand Down
18 changes: 18 additions & 0 deletions templates/redis.conf.epp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,24 @@
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize <%= bool2str($daemonize, 'yes', 'no') -%>

# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# requires "expect stop" in your upstart job config
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# on startup, and updating Redis status on a regular
# basis.
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous pings back to your supervisor.
#
# The default is "no". To run under upstart/systemd, you can simply uncomment
# the line below:
#
supervised auto

# When running daemonized, Redis writes a pid file in /var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile <%= $pid_file %>
Expand Down