Skip to content

Commit c888070

Browse files
author
Dan Bode
committed
Simplify looking up user defaults from params namespace
This commit simplifies the process by which the default value of $user is determined when not provided. The memcached class inherits from the params class so that the params class defaults are accessible as parameter defaults. It is worth noting that this code will not work with versions 2.6.0 -> 2.6.5 It is also worth noting that this will probably just be a temporary refactor until hiera becomes more pervasive.
1 parent 730a0c8 commit c888070

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

manifests/init.pp

+2-10
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,9 @@
55
$listen_ip = '0.0.0.0',
66
$tcp_port = '11211',
77
$udp_port = '11211',
8-
$user = '',
8+
$user = $::memcached::params::user,
99
$max_connections = '8192'
10-
) {
11-
12-
include memcached::params
13-
14-
if $user == '' {
15-
$user_real = $memcached::params::user
16-
} else {
17-
$user_real = $user
18-
}
10+
) inherits memcached::params {
1911

2012
package { $memcached::params::package_name:
2113
ensure => $package_ensure,

templates/memcached.conf.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ logfile <%= logfile %>
2626
-U <%= udp_port %>
2727

2828
# Run daemon as user
29-
-u <%= user_real %>
29+
-u <%= user %>
3030

3131
# Limit the number of simultaneous incoming connections.
3232
-c <%= max_connections %>

templates/memcached_sysconfig.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PORT="<%= udp_port %>"
2-
USER="<%= user_real %>"
2+
USER="<%= user %>"
33
MAXCONN="<%= max_connections %>"
44
CACHESIZE="<%= max_memory %>"
55
OPTIONS=""

0 commit comments

Comments
 (0)