diff --git a/.gitignore b/.gitignore index 6c68bc7fa..f90090294 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ pkg/ *.swp .forge-releng/ +Gemfile.lock diff --git a/manifests/init.pp b/manifests/init.pp index 1d196c333..08350ed0c 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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, @@ -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 @@ -43,7 +45,8 @@ } package { $memcached::params::package_name: - ensure => $package_ensure, + ensure => $package_ensure, + provider => $memcached::params::package_provider } if $install_dev { @@ -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: @@ -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] + } + } } diff --git a/manifests/params.pp b/manifests/params.pp index 20cb1ca51..1469a4b4d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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}") diff --git a/metadata.json b/metadata.json index 5ee9067f3..c4164ab4c 100644 --- a/metadata.json +++ b/metadata.json @@ -17,6 +17,9 @@ }, { "operatingsystem": "Ubuntu" + }, + { + "operatingsystem": "Windows" } ], "requirements": [ diff --git a/templates/memcached_windows.erb b/templates/memcached_windows.erb new file mode 100644 index 000000000..3964f2a91 --- /dev/null +++ b/templates/memcached_windows.erb @@ -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(' ') %>