Skip to content

Commit

Permalink
add disable-flush-all, disable-watch and memory-file parameter (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
saz authored Nov 12, 2024
1 parent 341c0ef commit d6ddc69
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 2 deletions.
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
String $config_tmpl = $memcached::params::config_tmpl,
Boolean $disable_cachedump = false,
Optional[Integer] $max_reqs_per_event = undef,
Boolean $disable_flush_all = false,
Boolean $disable_watch = false,
Optional[Stdlib::Absolutepath] $memory_file = undef,
) inherits memcached::params {
# Logging to syslog and file are mutually exclusive
# Fail if both options are defined
Expand Down
48 changes: 48 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,54 @@
it { is_expected.to contain_file('/etc/memcached.conf').with_content(%r{^-l 127.0.3.1,127.0.3.2$}) }
end
end

describe 'when setting disable_flush_all parameter to true' do
let :params do
{
'disable_flush_all' => true,
}
end

context 'on RedHat', if: facts[:os]['family'] == 'RedHat' do
it { is_expected.to contain_file('/etc/sysconfig/memcached').with_content(%r{^OPTIONS="-l 127.0.0.1 -U 0 -t \d+ --disable-flush-all }) }
end

context 'on Debian', if: facts[:os]['family'] == 'Debian' do
it { is_expected.to contain_file('/etc/memcached.conf').with_content(%r{^--disable-flush-all$}) }
end
end

describe 'when setting disable_watch parameter to true' do
let :params do
{
'disable_watch' => true,
}
end

context 'on RedHat', if: facts[:os]['family'] == 'RedHat' do
it { is_expected.to contain_file('/etc/sysconfig/memcached').with_content(%r{^OPTIONS="-l 127.0.0.1 -U 0 -t \d+ --disable-watch }) }
end

context 'on Debian', if: facts[:os]['family'] == 'Debian' do
it { is_expected.to contain_file('/etc/memcached.conf').with_content(%r{^--disable-watch$}) }
end
end

describe 'when setting memory_file parameter to /tmpfs_mount/memory_file' do
let :params do
{
'memory_file' => '/tmpfs_mount/memory_file',
}
end

context 'on RedHat', if: facts[:os]['family'] == 'RedHat' do
it { is_expected.to contain_file('/etc/sysconfig/memcached').with_content(%r{^OPTIONS="-l 127.0.0.1 -U 0 -t \d+ --memory-file=/tmpfs_mount/memory_file }) }
end

context 'on Debian', if: facts[:os]['family'] == 'Debian' do
it { is_expected.to contain_file('/etc/memcached.conf').with_content(%r{^--memory-file=/tmpfs_mount/memory_file$}) }
end
end
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions templates/memcached.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,15 @@ logfile <%= @logfile -%>
<% if @max_reqs_per_event -%>
-R <%= @max_reqs_per_event %>
<% end -%>
<% if @disable_flush_all -%>
--disable-flush-all
<% end -%>
<% if @disable_watch -%>
--disable-watch
<% end -%>
<% if @memory_file -%>
--memory-file=<%= @memory_file %>
<% end -%>
12 changes: 12 additions & 0 deletions templates/memcached_freebsd_rcconf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ end
if @max_reqs_per_event
flags << "-R #{@max_reqs_per_event}"
end

if @disable_flush_all
flags << "--disable-flush-all"
end

if @disable_watch
flags << "--disable-watch"
end

if @memory_file
flags << "--memory-file=#{@memory_file}"
end
-%>
memcached_enable="<%= enabled %>"
memcached_flags="<%= flags.join(" ") %>"
15 changes: 14 additions & 1 deletion templates/memcached_svcprop.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,18 @@ end

if @max_reqs_per_event
result << '"-R" "' + @max_reqs_per_event.to_s + '"'
end -%>
end

if @disable_flush_all
result << '"--disable-flush-all"'
end

if @disable_watch
result << '"--disable-watch"'
end

if @memory_file
result << '"--memory-file=' + @memory_file + '"'
end
-%>
<%= result.join(' ') -%>
12 changes: 12 additions & 0 deletions templates/memcached_sysconfig.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ if @use_sasl
result << '-S'
end

if @disable_flush_all
result << '--disable-flush-all'
end

if @disable_watch
result << '--disable-watch'
end

if @memory_file
result << '--memory-file=' + @memory_file
end

if !@logstdout
# log to syslog via logger
if @syslog && !@logfile
Expand Down
12 changes: 11 additions & 1 deletion templates/memcached_windows.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,15 @@ if @disable_cachedump
end
if @max_reqs_per_event
result << '-R' + @max_reqs_per_event.to_s
end -%>
end
if @disable_flush_all
result << '--disable-flush-all'
end
if @disable_watch
result << '--disable-watch'
end
if @memory_file
result << '--memory-file=' + @memory_file
end
-%>
c:\memcached\memcached.exe -d runservice <%= result.join(' ') %>

0 comments on commit d6ddc69

Please sign in to comment.