From dd3cc14e335e50fbfb179b046f35181163e729ed Mon Sep 17 00:00:00 2001 From: Thiago Almeida Date: Fri, 19 Jan 2018 12:05:24 -0200 Subject: [PATCH] Modifying mongod conf template. The new template will test if the systemLog option is file or syslog to add the correct file path options. --- tasks/configure.yml | 3 +++ templates/mongod.conf.j2 | 2 ++ templates/mongod_init.conf.j2 | 2 ++ 3 files changed, 7 insertions(+) diff --git a/tasks/configure.yml b/tasks/configure.yml index 940e94a..9b74a76 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -23,14 +23,17 @@ - name: Create log dir if missing file: state=directory recurse=yes dest={{ mongodb_systemlog_path|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755 + when: mongodb_systemlog_destination == "file" - name: Check than logfile exists stat: path={{ mongodb_systemlog_path }} register: logfile_stat + when: mongodb_systemlog_destination == "file" - name: Create log if missing file: state=touch dest={{ mongodb_systemlog_path }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755 when: logfile_stat is defined and not logfile_stat.stat.exists + when: mongodb_systemlog_destination == "file" - name: Ensure dbpath directory file: diff --git a/templates/mongod.conf.j2 b/templates/mongod.conf.j2 index 2ff5617..ba3ee92 100644 --- a/templates/mongod.conf.j2 +++ b/templates/mongod.conf.j2 @@ -53,8 +53,10 @@ storage: systemLog: destination: {{ mongodb_systemlog_destination }} + {% if mongodb_systemlog_destination == 'file' -%} logAppend: {{ mongodb_systemlog_logappend | to_nice_json }} path: {{ mongodb_systemlog_path }} + {% endif %} {% if mongodb_set_parameters -%} setParameter: diff --git a/templates/mongod_init.conf.j2 b/templates/mongod_init.conf.j2 index 9624f5f..2774560 100644 --- a/templates/mongod_init.conf.j2 +++ b/templates/mongod_init.conf.j2 @@ -41,5 +41,7 @@ storage: systemLog: destination: {{ mongodb_systemlog_destination }} + {% if mongodb_systemlog_destination == 'file' -%} logAppend: {{ mongodb_systemlog_logappend | to_nice_json }} path: {{ mongodb_systemlog_path }} + {% endif -%}