Skip to content

Commit

Permalink
Rebase from saz/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Kennedy committed May 19, 2015
2 parents b447489 + e0e9c02 commit bf3b9c6
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pkg/
*.swp
.forge-releng/
Gemfile.lock
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,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 'rspec', '< 3.2.0', {"platforms"=>["ruby_18"]}
gem 'puppet-lint', '>= 0.3.2'
gem 'facter', '>= 1.7.0', "< 1.8.0"
gem 'rspec-puppet', '=1.0.1'
32 changes: 23 additions & 9 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
class memcached (
$package_ensure = 'present',
$logfile = '/var/log/memcached.log',
$logfile = $::memcached::params::logfile,
$pidfile = '/var/run/memcached.pid',
$manage_firewall = false,
$max_memory = false,
Expand All @@ -22,6 +22,8 @@
$service_restart = true,
$auto_removal = false,
$use_sasl = false,
$use_registry = $::memcached::params::use_registry,
$registry_key = 'HKLM\System\CurrentControlSet\services\memcached\ImagePath',
$large_mem_pages = false,
$object_size = undef
) inherits memcached::params {
Expand All @@ -44,7 +46,8 @@
}

package { $memcached::params::package_name:
ensure => $package_ensure,
ensure => $package_ensure,
provider => $memcached::params::package_provider
}

if $install_dev {
Expand Down Expand Up @@ -74,13 +77,15 @@
$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],
notify => $service_notify_real,
if ( $memcached::params::config_file ) {
file { $memcached::params::config_file:
owner => 'root',
group => 'root',
mode => '0644',
content => template($memcached::params::config_tmpl),
require => Package[$memcached::params::package_name],
notify => $service_notify_real,
}
}

service { $memcached::params::service_name:
Expand All @@ -89,4 +94,13 @@
hasrestart => true,
hasstatus => $memcached::params::service_hasstatus,
}

if $use_registry {
registry_value{ $registry_key:
ensure => 'present',
type => 'string',
data => template($memcached::params::config_tmpl),
notify => Service[$memcached::params::service_name]
}
}
}
21 changes: 21 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,53 @@
case $::osfamily {
'Debian': {
$package_name = 'memcached'
$package_provider = undef
$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'
$logfile = '/var/log/memcached.log'
$use_registry = false
}
/RedHat|Suse/: {
$package_name = 'memcached'
$package_provider = undef
$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'
$logfile = '/var/log/memcached.log'
$use_registry = false
}
/windows/: {
$package_name = 'memcached'
$package_provider = 'chocolatey'
$service_name = 'memcached'
$service_hasstatus = true
$dev_package_name = 'libmemcached-devel'
$config_file = undef
$config_tmpl = "${module_name}/memcached_windows.erb"
$user = 'BUILTIN\Administrators'
$logfile = undef
$use_registry = true
}
default: {
case $::operatingsystem {
'Amazon': {
$package_name = 'memcached'
$package_provider = undef
$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'
$logfile = '/var/log/memcached.log'
$use_registry = false
}
default: {
fail("Unsupported platform: ${::osfamily}/${::operatingsystem}")
Expand Down
5 changes: 4 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"operatingsystem": "Ubuntu"
},
{
"operatingsystem": "Windows"
}
],
"requirements": [
Expand All @@ -30,7 +33,7 @@
}
],
"name": "saz-memcached",
"version": "2.6.0",
"version": "2.7.1",
"author": "saz",
"summary": "UNKNOWN",
"license": "Apache License, Version 2.0",
Expand Down
2 changes: 1 addition & 1 deletion templates/memcached_sysconfig.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
if @item_size
result << '-I ' + @item_size.to_s
end
result << '-t ' + @processorcount
result << '-t ' + @processorcount.to_s
if @logfile
result << '>> ' + @logfile + ' 2>&1'
end
Expand Down
28 changes: 28 additions & 0 deletions templates/memcached_windows.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%-
result = []
if @verbosity
result << '-' + @verbosity.to_s
end
if @lock_memory
result << '-k'
end
if @listen_ip
result << '-l ' + @listen_ip
end
if @tcp_port
result << '-p ' + @tcp_port.to_s
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 @max_connections
result << '-c ' + @max_connections
end
if @logfile
result << '>> ' + @logfile + ' 2>&1'
end -%>
c:\memcached\memcached.exe -d runservice <%= result.join(' ') %>

0 comments on commit bf3b9c6

Please sign in to comment.