Skip to content

Commit

Permalink
config mongodb verbose and use syslog as default
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermeindl committed Dec 18, 2024
1 parent e6712ee commit b342dea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 4 additions & 2 deletions roles/mongodb/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ mongodb_wiredtiger_directory_for_indexes: false
## systemLog Options
## The destination to which MongoDB sends all log output. Specify either 'file' or 'syslog'.
## If you specify 'file', you must also specify mongodb_systemlog_path.
mongodb_systemlog_destination: "file"
mongodb_systemlog_destination: syslog
mongodb_systemlog_logappend: true # Append to logpath instead of over-writing
mongodb_systemlog_logrotate: "rename" # Logrotation behavior
mongodb_systemlog_logrotate: rename # Logrotation behavior
mongodb_systemlog_path: /var/log/mongodb/{{ mongodb_daemon_name }}.log # Log file to send write to instead of stdout
# see https://www.mongodb.com/docs/v7.0/reference/configuration-options/#mongodb-setting-systemLog.verbosity
mongodb_systemlog_verbosity: 0

## operationProfiling Options
mongodb_operation_profiling_slow_op_threshold_ms: 100
Expand Down
13 changes: 7 additions & 6 deletions roles/mongodb/templates/mongod.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,18 @@ storage:
{% endif %}

systemLog:
verbosity: {{ mongodb_systemlog_verbosity }}
destination: {{ mongodb_systemlog_destination }}
{% if mongodb_systemlog_destination == 'file' -%}
{% if mongodb_systemlog_destination == 'file' %}
logAppend: {{ mongodb_systemlog_logappend | to_nice_json }}
logRotate: {{ mongodb_systemlog_logrotate }}
path: {{ mongodb_systemlog_path }}
{%- endif %}
{%- if mongodb_config['systemLog'] is defined and mongodb_config['systemLog'] is iterable %}
{%- for item in mongodb_config['systemLog'] -%}
{% endif %}
{% if mongodb_config['systemLog'] is defined and mongodb_config['systemLog'] is iterable %}
{% for item in mongodb_config['systemLog'] %}
{{ item }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

operationProfiling:
slowOpThresholdMs: {{ mongodb_operation_profiling_slow_op_threshold_ms }}
Expand Down
5 changes: 3 additions & 2 deletions roles/mongodb/templates/mongod_init.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ storage:
{% endif %}

systemLog:
verbosity: {{ mongodb_systemlog_verbosity }}
destination: {{ mongodb_systemlog_destination }}
{% if mongodb_systemlog_destination == 'file' -%}
{% if mongodb_systemlog_destination == 'file' %}
logAppend: {{ mongodb_systemlog_logappend | to_nice_json }}
logRotate: {{ mongodb_systemlog_logrotate }}
path: {{ mongodb_systemlog_path }}
{% endif -%}
{% endif %}

0 comments on commit b342dea

Please sign in to comment.