Skip to content

Commit

Permalink
Revert "cleanup some multi instance things"
Browse files Browse the repository at this point in the history
This reverts commit 0e45c9a.
  • Loading branch information
saz committed May 25, 2015
1 parent 0e45c9a commit cca1bb8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 41 deletions.
57 changes: 31 additions & 26 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down Expand Up @@ -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
}

Expand All @@ -82,4 +86,5 @@
}

create_resources(memcached::instance, $final_configs)

}
30 changes: 15 additions & 15 deletions manifests/instance.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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,
Expand All @@ -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}"
}
Expand All @@ -98,7 +98,7 @@
}
}

if $init_script {
if $::osfamily != 'Debian' {
file { $init_script:
owner => 'root',
group => 'root',
Expand Down

0 comments on commit cca1bb8

Please sign in to comment.