Sync puppet module memcached to v2.5.0 from upstream
v.2.5.0 sha1: 5a6c247a757671094d477d07c14b59c484d560d4 Implements: blueprint merge-openstack-puppet-modules Change-Id: I0f5dbe3b178d8805a92eadfe6516e467bc05abb3
This commit is contained in:
parent
d204858549
commit
c539543f54
|
@ -0,0 +1,10 @@
|
|||
fixtures:
|
||||
repositories:
|
||||
'firewall':
|
||||
repo: 'git://github.com/puppetlabs/puppetlabs-firewall.git'
|
||||
ref: '0.1.0'
|
||||
'stdlib':
|
||||
repo: 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
|
||||
ref: '3.2.0'
|
||||
symlinks:
|
||||
memcached: "#{source_dir}"
|
|
@ -0,0 +1,2 @@
|
|||
# Enforce Linux line-endings for template files on every operating system.
|
||||
*.erb text eol=lf
|
|
@ -1,5 +1,4 @@
|
|||
*.swp
|
||||
pkg/
|
||||
.DS_Store
|
||||
metadata.json
|
||||
coverage/
|
||||
*.swp
|
||||
/metadata.json
|
||||
.forge-releng/
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>memcached</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.cloudsmith.geppetto.pp.dsl.ui.modulefileBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.cloudsmith.geppetto.pp.dsl.ui.puppetNature</nature>
|
||||
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
language: ruby
|
||||
bundler_args: --without development
|
||||
script: 'bundle exec rake validate && bundle exec rake lint && SPEC_OPTS="--format documentation" bundle exec rake spec'
|
||||
after_success:
|
||||
- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng
|
||||
- .forge-releng/publish
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
env:
|
||||
matrix:
|
||||
- PUPPET_GEM_VERSION="~> 2.7.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.0.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.1.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.2.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.3.0"
|
||||
- PUPPET_GEM_VERSION="~> 3.4.0"
|
||||
global:
|
||||
- PUBLISHER_LOGIN=saz
|
||||
- secure: |-
|
||||
KHycFEf0ALVjITczYG0pcfk912muQkbJiGzKa5yyC8C9ppDW+dTYgDQu8AO1KXFHzds
|
||||
NUASY2XNjrJNv27w7A2eMp88qU1ID1s8CWALph4fuxGcM/HoPw9q8sldJ9/sHGlY9Ye
|
||||
DEeIvgt9qkwKtG/kb7dN7la42nv5fffWE95OU=
|
||||
matrix:
|
||||
include:
|
||||
- rvm: 2.0.0
|
||||
env: PUPPET_GEM_VERSION="~> 3.2.0"
|
||||
- rvm: 2.0.0
|
||||
env: PUPPET_GEM_VERSION="~> 3.3.0"
|
||||
- rvm: 1.8.7
|
||||
env: PUPPET_GEM_VERSION="~> 2.6.0"
|
||||
notifications:
|
||||
email: false
|
||||
gemfile: Gemfile
|
|
@ -0,0 +1,7 @@
|
|||
source "https://rubygems.org"
|
||||
|
||||
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
|
||||
gem 'puppet', puppetversion
|
||||
gem 'puppetlabs_spec_helper', '>= 0.1.0'
|
||||
gem 'puppet-lint', '>= 0.3.2'
|
||||
gem 'facter', '>= 1.7.0', "< 1.8.0"
|
|
@ -0,0 +1,14 @@
|
|||
Copyright 2011 Steffen Zieger
|
||||
Copyright 2014 Garrett Honeycutt <code@garretthoneycutt.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -1,8 +1,11 @@
|
|||
name 'saz-memcached'
|
||||
version '2.0.2'
|
||||
version '2.5.0'
|
||||
source 'git://github.com/saz/puppet-memcached.git'
|
||||
author 'saz'
|
||||
license 'Apache License, Version 2.0'
|
||||
summary 'UNKNOWN'
|
||||
description 'Manage memcached via Puppet'
|
||||
project_page 'https://github.com/saz/puppet-memcached'
|
||||
|
||||
dependency 'puppetlabs/stdlib', '>= 3.2.0'
|
||||
dependency 'puppetlabs/firewall', '>= 0.1.0'
|
||||
|
|
|
@ -1,29 +1,49 @@
|
|||
|
||||
# puppet-memcached
|
||||
# puppet-memcached [![Build Status](https://secure.travis-ci.org/saz/puppet-memcached.png)](http://travis-ci.org/saz/puppet-memcached)
|
||||
|
||||
Manage memcached via Puppet
|
||||
|
||||
## Show some love
|
||||
If you find this module useful, send some bitcoins to 1Na3YFUmdxKxJLiuRXQYJU2kiNqA3KY2j9
|
||||
|
||||
## How to use
|
||||
|
||||
### Use roughly 90% of memory
|
||||
|
||||
```
|
||||
```ruby
|
||||
class { 'memcached': }
|
||||
```
|
||||
|
||||
### Set a fixed memory limit in MB
|
||||
|
||||
```
|
||||
```ruby
|
||||
class { 'memcached':
|
||||
max_memory => 2048
|
||||
}
|
||||
```
|
||||
|
||||
### Use 12% of available memory
|
||||
|
||||
```ruby
|
||||
class { 'memcached':
|
||||
max_memory => '12%'
|
||||
}
|
||||
```
|
||||
|
||||
### Other class parameters
|
||||
|
||||
* $package_ensure = 'present'
|
||||
* $logfile = '/var/log/memcached.log'
|
||||
* $max_memory = false
|
||||
* $item_size = false
|
||||
* $lock_memory = false (WARNING: good if used intelligently, google for -k key)
|
||||
* $listen_ip = '0.0.0.0'
|
||||
* $tcp_port = 11211
|
||||
* $udp_port = 11211
|
||||
* $manage_firewall = false
|
||||
* $user = '' (OS specific setting, see params.pp)
|
||||
* $max_connections = 8192
|
||||
* $verbosity = undef
|
||||
* $unix_socket = undef
|
||||
* $install_dev = false (TRUE if 'libmemcached-dev' package should be installed)
|
||||
* $processorcount = $::processorcount
|
||||
* $service_restart = true (restart service after configuration changes, false to prevent restarts)
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'rspec/core/rake_task'
|
||||
require 'puppetlabs_spec_helper/rake_tasks'
|
||||
require 'puppet-lint/tasks/puppet-lint'
|
||||
PuppetLint.configuration.send('disable_80chars')
|
||||
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
|
||||
|
||||
task :default => [:spec]
|
||||
|
||||
desc "Run all module spec tests (Requires rspec-puppet gem)"
|
||||
RSpec::Core::RakeTask.new(:spec) do |t|
|
||||
t.rspec_opts = ['--color']
|
||||
# ignores fixtures directory.
|
||||
t.pattern = 'spec/{classes,defines,unit}/**/*_spec.rb'
|
||||
desc "Run puppet in noop mode and check for syntax errors."
|
||||
task :validate do
|
||||
Dir['manifests/**/*.pp'].each do |manifest|
|
||||
sh "puppet parser validate --noop #{manifest}"
|
||||
end
|
||||
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
|
||||
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
|
||||
end
|
||||
Dir['templates/**/*.erb'].each do |template|
|
||||
sh "erb -P -x -T '-' #{template} | ruby -c"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Build package"
|
||||
task :build do
|
||||
system("puppet-module build")
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
module Puppet::Parser::Functions
|
||||
newfunction(:memcached_max_memory, :type => :rvalue, :doc => <<-EOS
|
||||
Calculate max_memory size from fact 'memsize' and passed argument.
|
||||
EOS
|
||||
) do |arguments|
|
||||
|
||||
raise(Puppet::ParseError, "memcached_max_memory(): " +
|
||||
"Wrong number of arguments given " +
|
||||
"(#{arguments.size} for 1)") if arguments.size != 1
|
||||
|
||||
arg = arguments[0]
|
||||
memsize = lookupvar('memorysize')
|
||||
|
||||
if arg and !arg.to_s.end_with?('%')
|
||||
result_in_mb = arg.to_i
|
||||
else
|
||||
max_memory_percent = arg ? arg : '95%'
|
||||
|
||||
# Taken from puppetlabs-stdlib to_bytes() function
|
||||
value,prefix = */([0-9.e+-]*)\s*([^bB]?)/.match(memsize)[1,2]
|
||||
|
||||
value = value.to_f
|
||||
case prefix
|
||||
when '' then value = value
|
||||
when 'k' then value *= (1<<10)
|
||||
when 'M' then value *= (1<<20)
|
||||
when 'G' then value *= (1<<30)
|
||||
when 'T' then value *= (1<<40)
|
||||
when 'E' then value *= (1<<50)
|
||||
else raise Puppet::ParseError, "memcached_max_memory(): Unknown prefix #{prefix}"
|
||||
end
|
||||
value = value.to_i
|
||||
result_in_mb = ( (value / (1 << 20) ) * (max_memory_percent.to_f / 100.0) ).floor
|
||||
end
|
||||
|
||||
return result_in_mb
|
||||
end
|
||||
end
|
|
@ -1,39 +1,85 @@
|
|||
class memcached(
|
||||
# == Class: memcached
|
||||
#
|
||||
# Manage memcached
|
||||
#
|
||||
class memcached (
|
||||
$package_ensure = 'present',
|
||||
$logfile = '/var/log/memcached.log',
|
||||
$manage_firewall = false,
|
||||
$max_memory = false,
|
||||
$item_size = false,
|
||||
$lock_memory = false,
|
||||
$listen_ip = '0.0.0.0',
|
||||
$tcp_port = 11211,
|
||||
$udp_port = 11211,
|
||||
$user = $::memcached::params::user,
|
||||
$max_connections = '8192',
|
||||
$verbosity = undef,
|
||||
$unix_socket = undef
|
||||
$unix_socket = undef,
|
||||
$install_dev = false,
|
||||
$processorcount = $::processorcount,
|
||||
$service_restart = true
|
||||
) inherits memcached::params {
|
||||
|
||||
# validate type and convert string to boolean if necessary
|
||||
if type($manage_firewall) == 'String' {
|
||||
$manage_firewall_bool = str2bool($manage_firewall)
|
||||
} else {
|
||||
$manage_firewall_bool = $manage_firewall
|
||||
}
|
||||
validate_bool($manage_firewall_bool)
|
||||
validate_bool($service_restart)
|
||||
|
||||
if $package_ensure == 'absent' {
|
||||
$service_ensure = 'stopped'
|
||||
} else {
|
||||
$service_ensure = 'running'
|
||||
}
|
||||
|
||||
package { $memcached::params::package_name:
|
||||
ensure => $package_ensure,
|
||||
}
|
||||
|
||||
if $install_dev {
|
||||
package { $memcached::params::dev_package_name:
|
||||
ensure => $package_ensure,
|
||||
require => Package[$memcached::params::package_name]
|
||||
}
|
||||
}
|
||||
|
||||
if $manage_firewall_bool == true {
|
||||
firewall { "100_tcp_${tcp_port}_for_memcached":
|
||||
port => $tcp_port,
|
||||
proto => 'tcp',
|
||||
action => 'accept',
|
||||
}
|
||||
|
||||
firewall { "100_udp_${udp_port}_for_memcached":
|
||||
port => $udp_port,
|
||||
proto => 'udp',
|
||||
action => 'accept',
|
||||
}
|
||||
}
|
||||
|
||||
if $service_restart {
|
||||
$service_notify_real = Service[$memcached::params::service_name]
|
||||
} else {
|
||||
$service_notify_real = undef
|
||||
}
|
||||
|
||||
file { $memcached::params::config_file:
|
||||
owner => 'root',
|
||||
group => 'root',
|
||||
mode => '0644',
|
||||
content => template($memcached::params::config_tmpl),
|
||||
require => Package[$memcached::params::package_name],
|
||||
}
|
||||
|
||||
user {'memcached':
|
||||
ensure => present,
|
||||
system => true,
|
||||
notify => $service_notify_real,
|
||||
}
|
||||
|
||||
service { $memcached::params::service_name:
|
||||
ensure => running,
|
||||
ensure => $service_ensure,
|
||||
enable => true,
|
||||
hasrestart => true,
|
||||
hasstatus => false,
|
||||
subscribe => File[$memcached::params::config_file],
|
||||
require => [User['memcached']],
|
||||
hasstatus => $memcached::params::service_hasstatus,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,40 @@
|
|||
# == Class: memcached::params
|
||||
#
|
||||
class memcached::params {
|
||||
case $::osfamily {
|
||||
'Debian': {
|
||||
$package_name = 'memcached'
|
||||
$service_name = 'memcached'
|
||||
$config_file = '/etc/memcached.conf'
|
||||
$config_tmpl = "${module_name}/memcached.conf.erb"
|
||||
$user = 'nobody'
|
||||
$package_name = 'memcached'
|
||||
$service_name = 'memcached'
|
||||
$service_hasstatus = false
|
||||
$dev_package_name = 'libmemcached-dev'
|
||||
$config_file = '/etc/memcached.conf'
|
||||
$config_tmpl = "${module_name}/memcached.conf.erb"
|
||||
$user = 'nobody'
|
||||
}
|
||||
'RedHat': {
|
||||
$package_name = 'memcached'
|
||||
$service_name = 'memcached'
|
||||
$config_file = '/etc/sysconfig/memcached'
|
||||
$config_tmpl = "${module_name}/memcached_sysconfig.erb"
|
||||
$user = 'memcached'
|
||||
$package_name = 'memcached'
|
||||
$service_name = 'memcached'
|
||||
$service_hasstatus = true
|
||||
$dev_package_name = 'libmemcached-devel'
|
||||
$config_file = '/etc/sysconfig/memcached'
|
||||
$config_tmpl = "${module_name}/memcached_sysconfig.erb"
|
||||
$user = 'memcached'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported platform: ${::osfamily}")
|
||||
case $::operatingsystem {
|
||||
'Amazon': {
|
||||
$package_name = 'memcached'
|
||||
$service_name = 'memcached'
|
||||
$service_hasstatus = true
|
||||
$dev_package_name = 'libmemcached-devel'
|
||||
$config_file = '/etc/sysconfig/memcached'
|
||||
$config_tmpl = "${module_name}/memcached_sysconfig.erb"
|
||||
$user = 'memcached'
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported platform: ${::osfamily}/${::operatingsystem}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,65 @@
|
|||
require 'spec_helper'
|
||||
describe 'memcached' do
|
||||
|
||||
describe 'with manage_firewall parameter' do
|
||||
['Debian','RedHat'].each do |osfam|
|
||||
context "on osfamily #{osfam}" do
|
||||
let(:facts) do
|
||||
{ :osfamily => osfam,
|
||||
:memorysize => '1000 MB',
|
||||
:processorcount => '1',
|
||||
}
|
||||
end
|
||||
|
||||
['true',true].each do |value|
|
||||
context "set to #{value}" do
|
||||
let(:params) { { :manage_firewall => value } }
|
||||
|
||||
it { should contain_class('memcached') }
|
||||
|
||||
it { should contain_firewall('100_tcp_11211_for_memcached') }
|
||||
it { should contain_firewall('100_udp_11211_for_memcached') }
|
||||
end
|
||||
end
|
||||
|
||||
['false',false].each do |value|
|
||||
context "set to #{value}" do
|
||||
let(:params) { { :manage_firewall => value } }
|
||||
|
||||
it { should contain_class('memcached') }
|
||||
|
||||
it { should_not contain_firewall('100_tcp_11211_for_memcached') }
|
||||
it { should_not contain_firewall('100_udp_11211_for_memcached') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'set to an invalid type (array)' do
|
||||
let(:params) { { :manage_firewall => ['invalid','type'] } }
|
||||
|
||||
it do
|
||||
expect {
|
||||
should contain_class('memcached')
|
||||
}.to raise_error(Puppet::Error)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let :default_params do
|
||||
{
|
||||
:package_ensure => 'present',
|
||||
:logfile => '/var/log/memcached.log',
|
||||
:max_memory => false,
|
||||
:item_size => false,
|
||||
:lock_memory => false,
|
||||
:listen_ip => '0.0.0.0',
|
||||
:tcp_port => '11211',
|
||||
:udp_port => '11211',
|
||||
:user => 'nobody',
|
||||
:max_connections => '8192'
|
||||
:max_connections => '8192',
|
||||
:install_dev => false,
|
||||
:processorcount => 1
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -19,11 +68,29 @@ describe 'memcached' do
|
|||
:package_ensure => 'latest',
|
||||
:logfile => '/var/log/memcached.log',
|
||||
:max_memory => '2',
|
||||
:item_size => false,
|
||||
:lock_memory => true,
|
||||
:listen_ip => '127.0.0.1',
|
||||
:tcp_port => '11212',
|
||||
:udp_port => '11213',
|
||||
:user => 'somebdy',
|
||||
:max_connections => '8193'
|
||||
:max_connections => '8193',
|
||||
:verbosity => 'vvv',
|
||||
:processorcount => 3
|
||||
},
|
||||
{
|
||||
:package_ensure => 'present',
|
||||
:logfile => '/var/log/memcached.log',
|
||||
:max_memory => '20%',
|
||||
:lock_memory => false,
|
||||
:listen_ip => '127.0.0.1',
|
||||
:tcp_port => '11212',
|
||||
:udp_port => '11213',
|
||||
:user => 'somebdy',
|
||||
:max_connections => '8193',
|
||||
:verbosity => 'vvv',
|
||||
:install_dev => true,
|
||||
:processorcount => 1
|
||||
}
|
||||
].each do |param_set|
|
||||
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
|
||||
|
@ -41,23 +108,32 @@ describe 'memcached' do
|
|||
let :facts do
|
||||
{
|
||||
:osfamily => osfamily,
|
||||
:memorysize => '1',
|
||||
:memorysize => '1000 MB',
|
||||
:processorcount => '1',
|
||||
}
|
||||
end
|
||||
|
||||
describe "on supported osfamily: #{osfamily}" do
|
||||
|
||||
it { should contain_class('memcached::params') }
|
||||
it { should contain_class("memcached::params") }
|
||||
|
||||
it { should contain_package('memcached').with_ensure(param_hash[:package_ensure]) }
|
||||
it { should contain_package("memcached").with_ensure(param_hash[:package_ensure]) }
|
||||
|
||||
it { should contain_file('/etc/memcached.conf').with(
|
||||
it { should_not contain_firewall('100_tcp_11211_for_memcached') }
|
||||
it { should_not contain_firewall('100_udp_11211_for_memcached') }
|
||||
|
||||
it {
|
||||
if param_hash[:install_dev]
|
||||
should contain_package("libmemcached-dev").with_ensure(param_hash[:package_ensure])
|
||||
end
|
||||
}
|
||||
|
||||
it { should contain_file("/etc/memcached.conf").with(
|
||||
'owner' => 'root',
|
||||
'group' => 'root'
|
||||
)}
|
||||
|
||||
it { should contain_service('memcached').with(
|
||||
it { should contain_service("memcached").with(
|
||||
'ensure' => 'running',
|
||||
'enable' => true,
|
||||
'hasrestart' => true,
|
||||
|
@ -78,12 +154,22 @@ describe 'memcached' do
|
|||
"-U #{param_hash[:udp_port]}",
|
||||
"-u #{param_hash[:user]}",
|
||||
"-c #{param_hash[:max_connections]}",
|
||||
"-t #{facts[:processorcount]}"
|
||||
"-t #{param_hash[:processorcount]}"
|
||||
]
|
||||
if(param_hash[:max_memory])
|
||||
expected_lines.push("-m #{param_hash[:max_memory]}")
|
||||
if(param_hash[:max_memory].end_with?('%'))
|
||||
expected_lines.push("-m 200")
|
||||
else
|
||||
expected_lines.push("-m #{param_hash[:max_memory]}")
|
||||
end
|
||||
else
|
||||
expected_lines.push("-m #{((facts[:memorysize].to_f*1024)*0.95).floor}")
|
||||
expected_lines.push("-m 950")
|
||||
end
|
||||
if(param_hash[:lock_memory])
|
||||
expected_lines.push("-k")
|
||||
end
|
||||
if(param_hash[:verbosity])
|
||||
expected_lines.push("-vvv")
|
||||
end
|
||||
(content.split("\n") & expected_lines).should =~ expected_lines
|
||||
end
|
||||
|
|
|
@ -1,13 +1,2 @@
|
|||
require 'puppet'
|
||||
require 'rubygems'
|
||||
require 'rspec-puppet'
|
||||
|
||||
# get the value of a certain parameter
|
||||
def param_value(subject, type, title, param)
|
||||
subject.resource(type, title).send(:parameters)[param.to_sym]
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.module_path = File.join(File.dirname(__FILE__), '../../')
|
||||
c.manifest_dir = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures/manifests'))
|
||||
end
|
||||
require 'puppetlabs_spec_helper/module_spec_helper'
|
||||
|
|
|
@ -7,40 +7,47 @@
|
|||
-P /var/run/memcached.pid
|
||||
|
||||
# Log memcached's output
|
||||
logfile <%= logfile %>
|
||||
logfile <%= @logfile -%>
|
||||
|
||||
<% if @verbosity -%>
|
||||
# Verbosity
|
||||
-<%= verbosity %>
|
||||
-<%= @verbosity %>
|
||||
<% end -%>
|
||||
|
||||
# Use <num> MB memory max to use for object storage.
|
||||
<% if max_memory -%>
|
||||
-m <%= max_memory %>
|
||||
<% else -%>
|
||||
-m <%= ((memorysize.to_f*1024)*0.95).floor %>
|
||||
<% Puppet::Parser::Functions.function('memcached_max_memory') -%>
|
||||
-m <%= scope.function_memcached_max_memory([@max_memory]) %>
|
||||
|
||||
<% if @lock_memory -%>
|
||||
# Lock down all paged memory. There is a limit on how much memory you may lock.
|
||||
-k
|
||||
<% end -%>
|
||||
|
||||
<% if @unix_socket -%>
|
||||
# UNIX socket path to listen on
|
||||
-s <%= unix_socket %>
|
||||
-s <%= @unix_socket %>
|
||||
<% else -%>
|
||||
|
||||
# IP to listen on
|
||||
-l <%= listen_ip %>
|
||||
-l <%= @listen_ip %>
|
||||
|
||||
# TCP port to listen on
|
||||
-p <%= tcp_port %>
|
||||
-p <%= @tcp_port %>
|
||||
|
||||
# UDP port to listen on
|
||||
-U <%= udp_port %>
|
||||
-U <%= @udp_port %>
|
||||
<% end -%>
|
||||
|
||||
# Run daemon as user
|
||||
-u <%= user %>
|
||||
-u <%= @user %>
|
||||
|
||||
# Limit the number of simultaneous incoming connections.
|
||||
-c <%= max_connections %>
|
||||
-c <%= @max_connections %>
|
||||
|
||||
# Number of threads to use to process incoming requests.
|
||||
-t <%= processorcount %>
|
||||
-t <%= @processorcount %>
|
||||
|
||||
<% if @item_size -%>
|
||||
# Override the default size of each slab page
|
||||
-I <%= @item_size %>
|
||||
<% end -%>
|
||||
|
||||
|
|
|
@ -1,5 +1,27 @@
|
|||
PORT="<%= @udp_port %>"
|
||||
PORT="<%= @tcp_port %>"
|
||||
USER="<%= @user %>"
|
||||
MAXCONN="<%= @max_connections %>"
|
||||
CACHESIZE="<%= @max_memory %>"
|
||||
OPTIONS="-l <%= @listen_ip %>"
|
||||
<% Puppet::Parser::Functions.function('memcached_max_memory') -%>
|
||||
CACHESIZE="<%= scope.function_memcached_max_memory([@max_memory]) %>"
|
||||
OPTIONS="<%
|
||||
result = []
|
||||
if @verbosity
|
||||
result << '-' + @verbosity.to_s
|
||||
end
|
||||
if @lock_memory
|
||||
result << '-k'
|
||||
end
|
||||
if @listen_ip
|
||||
result << '-l ' + @listen_ip
|
||||
end
|
||||
if @udp_port
|
||||
result << '-U ' + @udp_port.to_s
|
||||
end
|
||||
if @item_size
|
||||
result << '-I ' + @item_size.to_s
|
||||
end
|
||||
result << '-t ' + @processorcount
|
||||
if @logfile
|
||||
result << '>> ' + @logfile + ' 2>&1'
|
||||
end
|
||||
-%><%= result.join(' ') -%>"
|
||||
|
|
Loading…
Reference in New Issue