From d21b80a6e25a21d2dfda78b1f2ecf434a0e498bb Mon Sep 17 00:00:00 2001 From: Seth Miller Date: Mon, 17 Nov 2014 13:10:20 -0600 Subject: [PATCH] add RedHat config file support --- memcached/config.sls | 8 +++++++- memcached/map.jinja | 2 ++ memcached/templates/sysconfig/memcached | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 memcached/templates/sysconfig/memcached diff --git a/memcached/config.sls b/memcached/config.sls index f495c70..dd1214e 100644 --- a/memcached/config.sls +++ b/memcached/config.sls @@ -1,13 +1,19 @@ +{% from 'memcached/map.jinja' import memcached with context %} + include: - memcached -/etc/memcached.conf: +{{ memcached.config_file }}: file: - managed - template: jinja - user: root - group: root - mode: 644 + {% if grains['os_family'] == 'Debian' %} - source: salt://memcached/templates/memcached.conf + {% elif grains['os_family'] == 'RedHat' %} + - source: salt://memcached/templates/sysconfig/memcached + {% endif %} - watch_in: - service: memcached diff --git a/memcached/map.jinja b/memcached/map.jinja index f501da1..cc2224f 100644 --- a/memcached/map.jinja +++ b/memcached/map.jinja @@ -18,10 +18,12 @@ 'server': 'memcached', 'service': 'memcached', 'python': 'python-memcache', + 'config_file': '/etc/memcached.conf', }, 'RedHat': { 'server': 'memcached', 'service': 'memcached', 'python': 'python-memcached', + 'config_file': '/etc/sysconfig/memcached', }, }, merge=salt['pillar.get']('memcached:lookup')) %} diff --git a/memcached/templates/sysconfig/memcached b/memcached/templates/sysconfig/memcached new file mode 100644 index 0000000..3e06707 --- /dev/null +++ b/memcached/templates/sysconfig/memcached @@ -0,0 +1,25 @@ +{% from 'memcached/macros.sls' import get_config_item with context -%} + +PORT="{{ get_config_item('port') }}" +USER="{{ get_config_item('user') }}" +MAXCONN="{{ get_config_item('max_connections') }}" +CACHESIZE="{{ get_config_item('memory_cap') }}" +OPTIONS="-l {{ get_config_item('listen_address') }}" + +{% if get_config_item('lock_paged_memory') == 'True' %} +OPTIONS="$OPTIONS -k" +{% endif %} + +{% if get_config_item('error_on_mem_full') == 'True' %} +OPTIONS="$OPTIONS -M" +{% endif %} + +{% if get_config_item('max_core_file_"limit') == 'True' %} +OPTIONS="$OPTIONS -r" +{% endif %} + +{% if get_config_item('verbose_level') == '1' %} +OPTIONS="$OPTIONS -v >> {{ get_config_item('log_file') }} 2>&1" +{% elif get_config_item('verbose_level') == '2' %} +OPTIONS="$OPTIONS -vv >> {{ get_config_item('log_file') }} 2>&1" +{% endif %}