Skip to content

Commit

Permalink
Merge pull request #52 from sanoma-technology/master
Browse files Browse the repository at this point in the history
Add windows support
  • Loading branch information
saz committed Mar 28, 2015
2 parents 5869cad + e908d4e commit f977167
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 10 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
34 changes: 24 additions & 10 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,7 +22,9 @@
$service_restart = true,
$auto_removal = false,
$use_sasl = false,
$large_mem_pages = false,
$use_registry = $::memcached::params::use_registry,
$registry_key = 'HKLM\System\CurrentControlSet\services\memcached\ImagePath',
$large_mem_pages = false
) inherits memcached::params {

# validate type and convert string to boolean if necessary
Expand All @@ -43,7 +45,8 @@
}

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

if $install_dev {
Expand Down Expand Up @@ -73,13 +76,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 @@ -88,4 +93,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
3 changes: 3 additions & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
},
{
"operatingsystem": "Ubuntu"
},
{
"operatingsystem": "Windows"
}
],
"requirements": [
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 f977167

Please sign in to comment.