From 2d937511d63002ec730da36fa5e89424017c4299 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Wed, 13 Apr 2016 13:36:28 +0100 Subject: [PATCH] Improved logging for memcached - Moved to the right folder to get it accessed on bare metal when containerized - Making it work for rsyslog and logrotation's existing roles - Changed the gate tests to reflect path change Closes-Bug: #1569171 Change-Id: I3a1c2f50ab63b55b39318ba40c0921f6b738cafb --- defaults/main.yml | 6 +++++- tasks/memcached_config.yml | 5 +++++ templates/memcached.conf | 7 +++++++ tests/test.yml | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 9a1d542..fd70116 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +## Verbosity Options +debug: False +verbose: False + ## APT Cache Options cache_timeout: 600 @@ -28,7 +32,7 @@ memcached_memory: "{{ base_memcached_memory | int // 4 if base_memcached_memory memcached_port: 11211 memcached_user: memcache memcached_listen: "127.0.0.1" -memcached_log: /var/log/memcached.log +memcached_log: /var/log/memcached/memcached.log memcached_connections: 1024 memcached_threads: 4 diff --git a/tasks/memcached_config.yml b/tasks/memcached_config.yml index 52aa7a8..3436cc3 100644 --- a/tasks/memcached_config.yml +++ b/tasks/memcached_config.yml @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Ensure logging folder exists + file: + path: "{{ memcached_log | dirname }}" + state: directory + - name: Apply memcached config template: src: "memcached.conf" diff --git a/templates/memcached.conf b/templates/memcached.conf index efd0cf5..6f16343 100644 --- a/templates/memcached.conf +++ b/templates/memcached.conf @@ -1,6 +1,13 @@ # {{ ansible_managed }} -d +{% if debug | bool %} +-vvv +{% elif verbose | bool %} +-vv +{% else %} +-v +{% endif %} logfile {{ memcached_log }} -m {{ memcached_memory }} -p {{ memcached_port }} diff --git a/tests/test.yml b/tests/test.yml index 596dd27..1c1226b 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -28,7 +28,7 @@ memcached_file_content: "{{ memcached_file.content | b64decode }}" - name: Open memcached log file stat: - path: /var/log/memcached.log + path: /var/log/memcached/memcached.log register: memcached_log - name: Check memcache is running shell: ps auxfww | grep 'memcache' @@ -36,7 +36,7 @@ assert: that: - "memcached_log.stat.exists" - - "'logfile /var/log/memcached.log' in memcached_file_content" + - "'logfile /var/log/memcached/memcached.log' in memcached_file_content" - "'-l 127.0.0.1' in memcached_file_content" - "'-c 1024' in memcached_file_content" - "'-t 4' in memcached_file_content"