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

Allow empty unixsocket(perm) #333

Merged
merged 1 commit into from
Dec 2, 2019
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
8 changes: 4 additions & 4 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,15 @@ Default value: 65536

##### `unixsocket`

Data type: `Stdlib::Absolutepath`
Data type: `Variant[Stdlib::Absolutepath, Enum['']]`
ekohl marked this conversation as resolved.
Show resolved Hide resolved

Define unix socket path

Default value: '/var/run/redis/redis.sock'

##### `unixsocketperm`

Data type: `Stdlib::Filemode`
Data type: `Variant[Stdlib::Filemode, Enum['']]`

Define unix socket file permissions

Expand Down Expand Up @@ -1845,15 +1845,15 @@ Default value: $redis::ulimit

##### `unixsocket`

Data type: `Stdlib::Absolutepath`
Data type: `Variant[Stdlib::Absolutepath, Enum['']]`

Define unix socket path

Default value: "/var/run/redis/redis-server-${name}.sock"

##### `unixsocketperm`

Data type: `Stdlib::Filemode`
Data type: `Variant[Stdlib::Filemode , Enum['']]`

Define unix socket file permissions

Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@
Integer[0] $tcp_backlog = 511,
Integer[0] $tcp_keepalive = 0,
Integer[0] $timeout = 0,
Stdlib::Absolutepath $unixsocket = '/var/run/redis/redis.sock',
Stdlib::Filemode $unixsocketperm = '0755',
Variant[Stdlib::Absolutepath, Enum['']] $unixsocket = '/var/run/redis/redis.sock',
Variant[Stdlib::Filemode, Enum['']] $unixsocketperm = '0755',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the template allowed it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see only one use case , let the default umask manage the perm of the file.
Bah ... not sure it is useful, but why not.

Integer[0] $ulimit = 65536,
Stdlib::Absolutepath $workdir = $redis::params::workdir,
Stdlib::Filemode $workdir_mode = '0750',
Expand Down
4 changes: 2 additions & 2 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
Integer[0] $tcp_backlog = $redis::tcp_backlog,
Integer[0] $tcp_keepalive = $redis::tcp_keepalive,
Integer[0] $timeout = $redis::timeout,
Stdlib::Filemode $unixsocketperm = $redis::unixsocketperm,
Variant[Stdlib::Filemode , Enum['']] $unixsocketperm = $redis::unixsocketperm,
Integer[0] $ulimit = $redis::ulimit,
Stdlib::Filemode $workdir_mode = $redis::workdir_mode,
Integer[0] $zset_max_ziplist_entries = $redis::zset_max_ziplist_entries,
Expand All @@ -287,7 +287,7 @@
Boolean $manage_service_file = true,
Optional[Stdlib::Absolutepath] $log_file = undef,
Stdlib::Absolutepath $pid_file = "/var/run/redis/redis-server-${name}.pid",
Stdlib::Absolutepath $unixsocket = "/var/run/redis/redis-server-${name}.sock",
Variant[Stdlib::Absolutepath, Enum['']] $unixsocket = "/var/run/redis/redis-server-${name}.sock",
Stdlib::Absolutepath $workdir = "${redis::workdir}/redis-server-${name}",
) {

Expand Down
36 changes: 18 additions & 18 deletions spec/classes/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,31 +464,31 @@
end

describe 'with parameter unixsocket' do
let(:params) do
{
unixsocket: '/tmp/redis.sock'
}
describe '/tmp/redis.sock' do
let(:params) { { unixsocket: '/tmp/redis.sock' } }

it { is_expected.to contain_file(config_file_orig).with_content(%r{^unixsocket /tmp/redis\.sock$}) }
end

it {
is_expected.to contain_file(config_file_orig).with(
'content' => %r{unixsocket.*/tmp/redis\.sock}
)
}
describe 'empty string' do
let(:params) { { unixsocket: '' } }

it { is_expected.to contain_file(config_file_orig).without_content(%r{^unixsocket }) }
end
end

describe 'with parameter unixsocketperm' do
let(:params) do
{
unixsocketperm: '777'
}
describe '777' do
let(:params) { { unixsocketperm: '777' } }

it { is_expected.to contain_file(config_file_orig).with_content(%r{^unixsocketperm 777$}) }
end

it {
is_expected.to contain_file(config_file_orig).with(
'content' => %r{unixsocketperm.*777}
)
}
describe 'empty string' do
let(:params) { { unixsocketperm: '' } }

it { is_expected.to contain_file(config_file_orig).without_content(%r{^unixsocketperm }) }
end
end

describe 'with parameter masterauth' do
Expand Down
6 changes: 4 additions & 2 deletions templates/redis.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ tcp-backlog <%= @tcp_backlog %>
bind <%= @bind_arr.join(' ') %>
<% end -%>

<% unless @unixsocket.empty? -%>
# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
<% if @unixsocket %>unixsocket <%= @unixsocket %><% end %>
<% if @unixsocketperm %>unixsocketperm <%= @unixsocketperm %><% end %>
unixsocket <%= @unixsocket %>
<% unless @unixsocketperm.empty? %>unixsocketperm <%= @unixsocketperm %><% end -%>

<% end -%>
# Close the connection after a client is idle for N seconds (0 to disable)
timeout <%= @timeout %>

Expand Down