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

Add some additional parameters for ownerships #429

Merged
merged 4 commits into from
Mar 12, 2024
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
48 changes: 48 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ The following parameters are available in the `redis` class:
* [`unixsocketperm`](#-redis--unixsocketperm)
* [`workdir`](#-redis--workdir)
* [`workdir_mode`](#-redis--workdir_mode)
* [`workdir_group`](#-redis--workdir_group)
* [`workdir_owner`](#-redis--workdir_owner)
* [`debdefault_group`](#-redis--debdefault_group)
* [`debdefault_file_mode`](#-redis--debdefault_file_mode)
* [`debdefault_owner`](#-redis--debdefault_owner)
* [`zset_max_ziplist_entries`](#-redis--zset_max_ziplist_entries)
* [`zset_max_ziplist_value`](#-redis--zset_max_ziplist_value)
* [`cluster_enabled`](#-redis--cluster_enabled)
Expand Down Expand Up @@ -1161,6 +1166,49 @@ Adjust mode for data directory.

Default value: `'0750'`

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

Data type: `Optional[String[1]]`

Adjust filesystem group for $workdir.

Default value: `undef`

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

Data type: `Optional[String[1]]`

Adjust filesystem owner for $workdir.

Default value: `undef`

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

Data type: `Optional[String[1]]`

group of /etc/defaults/redis on Debian systems
if undef, $redis::config_group is taken

Default value: `undef`

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

Data type: `Optional[Stdlib::Filemode]`

filemode of /etc/defaults/redis on Debian systems
if undef, $redis::config_file_mode is taken

Default value: `undef`

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

Data type: `Optional[String[1]]`

owner of /etc/defaults/redis on Debian systems
if undef, $redis::config_owner is taken

Default value: `undef`

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

Data type: `Integer[0]`
Expand Down
10 changes: 5 additions & 5 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

file { $redis::workdir:
ensure => directory,
group => $redis::service_group,
group => pick($redis::workdir_group, $redis::service_group),
mode => $redis::workdir_mode,
owner => $redis::service_user,
owner => pick($redis::workdir_owner, $redis::service_user),
}

if $redis::default_install {
Expand All @@ -48,9 +48,9 @@
'Debian': {
file { '/etc/default/redis-server':
ensure => file,
group => $redis::config_group,
mode => $redis::config_file_mode,
owner => $redis::config_owner,
group => pick($redis::debdefault_group, $redis::config_group),
mode => pick($redis::debdefault_file_mode, $redis::config_file_mode),
owner => pick($redis::debdefault_owner, $redis::config_owner),
}
}

Expand Down
18 changes: 18 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,19 @@
# above using the 'dbfilename' configuration directive.
# @param workdir_mode
# Adjust mode for data directory.
# @param workdir_group
# Adjust filesystem group for $workdir.
# @param workdir_owner
# Adjust filesystem owner for $workdir.
# @param debdefault_group
# group of /etc/defaults/redis on Debian systems
# if undef, $redis::config_group is taken
# @param debdefault_file_mode
# filemode of /etc/defaults/redis on Debian systems
# if undef, $redis::config_file_mode is taken
# @param debdefault_owner
# owner of /etc/defaults/redis on Debian systems
# if undef, $redis::config_owner is taken
# @param zset_max_ziplist_entries
# Set max entries for sorted sets.
# @param zset_max_ziplist_value
Expand Down Expand Up @@ -455,6 +468,11 @@
Boolean $ulimit_managed = true,
Stdlib::Absolutepath $workdir = $redis::params::workdir,
Stdlib::Filemode $workdir_mode = '0750',
Optional[String[1]] $workdir_group = undef,
Optional[String[1]] $workdir_owner = undef,
Optional[String[1]] $debdefault_group = undef,
Optional[Stdlib::Filemode] $debdefault_file_mode = undef,
Optional[String[1]] $debdefault_owner = undef,
Integer[0] $zset_max_ziplist_entries = 128,
Integer[0] $zset_max_ziplist_value = 64,
Boolean $cluster_enabled = false,
Expand Down
57 changes: 57 additions & 0 deletions spec/classes/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,63 @@ class { 'redis':
it { is_expected.to contain_systemd__unit_file("#{service_name}.service").with('content' => %r{^TimeoutStartSec=600$}) }
it { is_expected.to contain_systemd__unit_file("#{service_name}.service").with('content' => %r{^TimeoutStopSec=300$}) }
end

describe 'with non default ownership' do
let :params do
{
workdir: '/tmp/rediswork',
workdir_group: 'wdirgroup',
workdir_owner: 'wdirowner',
config_group: 'cfggroup',
}
end

it {
is_expected.to contain_file('/tmp/rediswork').with(
'ensure' => 'directory',
'owner' => 'wdirowner',
'group' => 'wdirgroup',
'mode' => '0750'
)
}

if facts[:os]['family'] == 'Debian'
it {
is_expected.to contain_file('/etc/default/redis-server').
with(
'ensure' => 'file',
'owner' => 'redis',
'group' => 'cfggroup',
'mode' => '0640'
)
}
end
end

describe 'overwrite debian directory config' do
let :params do
{
config_owner: 'redis',
config_group: 'cfggroup',
config_file_mode: '0333',
debdefault_group: 'dd_group',
debdefault_owner: 'dd_owner',
debdefault_file_mode: '0242',
}
end

if facts[:os]['family'] == 'Debian'
it {
is_expected.to contain_file('/etc/default/redis-server').
with(
'ensure' => 'file',
'owner' => 'dd_owner',
'group' => 'dd_group',
'mode' => '0242'
)
}
end
end
end
end
end
Expand Down