Skip to content

Commit

Permalink
Resolving conflicts with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
ghoneycutt committed Feb 1, 2014
2 parents 35f17c2 + d009260 commit 30b31d6
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 58 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pkg/
*.swp
/metadata.json
/metadata.json
.forge-releng/
42 changes: 31 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
language: ruby
rvm:
- 1.8.7
before_script:
after_script:
script: "rake spec"
---
branches:
only:
- master
language: ruby
bundler_args: --without development
script: bundle exec rake spec SPEC_OPTS='--format documentation'
after_success:
- git clone -q git://github.com/puppetlabs/ghpublisher.git .forge-releng
- .forge-releng/publish
rvm:
- 1.8.7
- 1.9.3
env:
- PUPPET_VERSION=2.7.13
- PUPPET_VERSION=2.7.6
- PUPPET_VERSION=2.6.9
- PUPPET_VERSION=3.0.0
- PUPPET_VERSION=3.4.2
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
2 changes: 1 addition & 1 deletion Modulefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name 'saz-memcached'
version '2.1.0'
version '2.2.4'
source 'git://github.com/saz/puppet-memcached.git'
author 'saz'
license 'Apache License, Version 2.0'
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# puppet-memcached

[![Build Status](https://secure.travis-ci.org/saz/puppet-memcached.png)](http://travis-ci.org/saz/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
Expand All @@ -30,12 +31,18 @@ Manage memcached via Puppet

### 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
* $lock_memory = false (WARNING: good if used intelligently, google for -k key)
* $verbosity = undef
* $unix_socket = undef
* $install_dev = false (TRUE if 'libmemcached-dev' package should be installed)
* $processorcount = $::processorcount
14 changes: 11 additions & 3 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$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,
Expand All @@ -11,7 +12,8 @@
$max_connections = '8192',
$verbosity = undef,
$unix_socket = undef,
$install_dev = false
$install_dev = false,
$processorcount = $::processorcount
) inherits memcached::params {

# validate type and convert string to boolean if necessary
Expand All @@ -22,6 +24,12 @@
}
validate_bool($manage_firewall_bool)

if $package_ensure == 'absent' {
$service_ensure = 'stopped'
} else {
$service_ensure = 'running'
}

package { $memcached::params::package_name:
ensure => $package_ensure,
}
Expand Down Expand Up @@ -56,10 +64,10 @@
}

service { $memcached::params::service_name:
ensure => running,
ensure => $service_ensure,
enable => true,
hasrestart => true,
hasstatus => false,
hasstatus => $memcached::params::service_hasstatus,
subscribe => File[$memcached::params::config_file],
}
}
26 changes: 14 additions & 12 deletions manifests/params.pp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
class memcached::params {
case $::osfamily {
'Debian': {
$package_name = 'memcached'
$service_name = 'memcached'
$dev_package_name = 'libmemcached-dev'
$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'
$dev_package_name = 'libmemcached-devel'
$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}")
Expand Down
29 changes: 21 additions & 8 deletions spec/classes/memcached_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@
: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

Expand All @@ -65,13 +68,15 @@
: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',
:verbosity => 'vvv'
:verbosity => 'vvv',
:processorcount => 3
},
{
:package_ensure => 'present',
Expand All @@ -83,7 +88,9 @@
:udp_port => '11213',
:user => 'somebdy',
:max_connections => '8193',
:verbosity => 'vvv'
:verbosity => 'vvv',
:install_dev => true,
:processorcount => 1
}
].each do |param_set|
describe "when #{param_set == {} ? "using default" : "specifying"} class parameters" do
Expand All @@ -108,19 +115,25 @@

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_not contain_firewall('100_tcp_11211_for_memcached') }
it { should_not contain_firewall('100_udp_11211_for_memcached') }

it { should contain_file('/etc/memcached.conf').with(
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,
Expand All @@ -141,7 +154,7 @@
"-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])
if(param_hash[:max_memory].end_with?('%'))
Expand Down
26 changes: 16 additions & 10 deletions templates/memcached.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
-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.
<% Puppet::Parser::Functions.function('memcached_max_memory') -%>
-m <%= scope.function_memcached_max_memory([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.
Expand All @@ -25,23 +25,29 @@ logfile <%= logfile -%>

<% 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 -%>

19 changes: 11 additions & 8 deletions templates/memcached_sysconfig.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
PORT="<%= tcp_port %>"
USER="<%= user %>"
MAXCONN="<%= max_connections %>"
PORT="<%= @tcp_port %>"
USER="<%= @user %>"
MAXCONN="<%= @max_connections %>"
<% Puppet::Parser::Functions.function('memcached_max_memory') -%>
CACHESIZE="<%= scope.function_memcached_max_memory([max_memory]) %>"
CACHESIZE="<%= scope.function_memcached_max_memory([@max_memory]) %>"
OPTIONS="<%
result = []
if @verbosity
result << '-' + verbosity
result << '-' + @verbosity
end
if @lock_memory
result << '-k'
end
if @listen_ip
result << '-l ' + listen_ip
result << '-l ' + @listen_ip
end
if @udp_port
result << '-U ' + udp_port
result << '-U ' + @udp_port
end
result << '-t ' + processorcount
if @item_size
result << '-I ' + @item_size
end
result << '-t ' + @processorcount
-%><%= result.join(' ') -%>"

0 comments on commit 30b31d6

Please sign in to comment.