Skip to content

Commit

Permalink
Merge pull request voxpupuli#333 from ekohl/empty-unixsocket
Browse files Browse the repository at this point in the history
Allow empty unixsocket(perm)
  • Loading branch information
ekohl committed Dec 2, 2019
2 parents 24c6d47 + 5cb64d4 commit 0682e6a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
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['']]`

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 @@ -1837,15 +1837,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',
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 @@ -263,7 +263,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 @@ -283,7 +283,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 @@ -454,31 +454,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

0 comments on commit 0682e6a

Please sign in to comment.