From cca1bb8dd6c29d2a9bb03b5edb0c5ac7df27f759 Mon Sep 17 00:00:00 2001 From: Steffen Zieger Date: Mon, 25 May 2015 20:48:09 +0200 Subject: [PATCH] Revert "cleanup some multi instance things" This reverts commit 0e45c9a8d6198066031a08da530593a492155659. --- manifests/init.pp | 57 +++++++++++++++++++++++-------------------- manifests/instance.pp | 30 +++++++++++------------ 2 files changed, 46 insertions(+), 41 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8253fce29..81c228f4d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -3,28 +3,28 @@ # Manage memcached # class memcached ( - $package_ensure = 'present', - $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, - $install_dev = false, - $processorcount = $::processorcount, - $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, - $default_instance = true, - $instance_configs = hiera_hash('memcached::instance_configs', {}) + $package_ensure = 'present', + $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, + $install_dev = false, + $processorcount = $::processorcount, + $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, + $default_instance = true, + $instance_configs = hiera_hash('memcached::instance_configs', undef), ) inherits memcached::params { if $package_ensure == 'absent' { @@ -60,11 +60,15 @@ }, } - validate_hash($instance_configs) - - if $default_instance { + if $default_instance and is_hash($instance_configs) { + validate_hash($instance_configs) $final_configs = merge($default_configs, $instance_configs) - } else { + } + elsif $default_instance { + $final_configs = $default_configs + } + elsif is_hash($instance_configs) { + validate_hash($instance_configs) $final_configs = $instance_configs } @@ -82,4 +86,5 @@ } create_resources(memcached::instance, $final_configs) + } diff --git a/manifests/instance.pp b/manifests/instance.pp index c7893493e..6e4edd889 100644 --- a/manifests/instance.pp +++ b/manifests/instance.pp @@ -21,20 +21,11 @@ $use_sasl = false, $large_mem_pages = false, $service_ensure = 'running', - $service_enable = true + $service_enable = true, ) { include ::memcached::params - # validate type and convert string to boolean if necessary - if is_string($manage_firewall) { - $manage_firewall_bool = str2bool($manage_firewall) - } else { - $manage_firewall_bool = $manage_firewall - } - validate_bool($manage_firewall_bool) - validate_bool($service_restart) - # This is needed only if instances are exclusively defined rather than using the base class if ! defined(Class['::memcached::package']) { class { '::memcached::package': @@ -46,6 +37,19 @@ $user = $memcached::params::user $pidfile = "/var/run/memcached_${tcp_port}.pid" + if $::osfamily != 'Windows' { + $logfile = "/var/log/memcached_${tcp_port}.log" + } + + # validate type and convert string to boolean if necessary + if is_string($manage_firewall) { + $manage_firewall_bool = str2bool($manage_firewall) + } else { + $manage_firewall_bool = $manage_firewall + } + validate_bool($manage_firewall_bool) + validate_bool($service_restart) + if $manage_firewall_bool == true { firewall { "100_tcp_${tcp_port}_for_memcached": port => $tcp_port, @@ -63,19 +67,15 @@ case $::osfamily { 'Debian': { $config_file = "/etc/memcached_${tcp_port}.conf" - $logfile = "/var/log/memcached_${tcp_port}.log" $service_name = 'memcached' - $init_script = false # We don't manage the init script for Debian } 'Windows': { $config_file = undef $service_name = 'memcached' - $init_script = false } default: { $config_file = "/etc/sysconfig/memcached_${tcp_port}" - $logfile = "/var/log/memcached_${tcp_port}.log" $service_name = "memcached_${tcp_port}" $init_script = "/etc/init.d/memcached_${tcp_port}" } @@ -98,7 +98,7 @@ } } - if $init_script { + if $::osfamily != 'Debian' { file { $init_script: owner => 'root', group => 'root',