diff --git a/mongodb-org-3.2/defaults/main.yml b/mongodb-org-3.2/defaults/main.yml index 4a27e504..49b8a1ae 100644 --- a/mongodb-org-3.2/defaults/main.yml +++ b/mongodb-org-3.2/defaults/main.yml @@ -16,7 +16,6 @@ mongodb_logdir: /var/log/mongodb mongodb_log_file: mongod.log mongodb_logpath: '{{ mongodb_logdir }}/{{ mongodb_log_file }}' mongodb_dbpath: /var/lib/mongodb -mongodb_log_retain_days: 7 mongodb_directoryperdb: 'false' mongodb_conf_file: /etc/mongod.conf mongodb_daemon: /usr/bin/mongod @@ -27,11 +26,14 @@ mongodb_allowed_hosts: mongodb_storage_engine: wiredTiger +# Do not change the default. We do not manage a logrotate configuration yet +mongodb_systemlog_external_logrotate: False mongodb_systemlog_destination: file +mongodb_log_retain_days: 7 +# Not used anymore inside the template. Now we use different values based on mongodb_systemlog_external_logrotate mongodb_systemlog_logappend: 'true' mongodb_systemlog_logrotate: reopen - mongodb_cluster_enabled: False mongodb_replicaset: storagedev mongodb_replica_keyfile: '{{ mongodb_dbpath }}/replica_keyfile' diff --git a/mongodb-org-3.2/tasks/mongodb.yml b/mongodb-org-3.2/tasks/mongodb.yml index 92ebbe92..1fa99855 100644 --- a/mongodb-org-3.2/tasks/mongodb.yml +++ b/mongodb-org-3.2/tasks/mongodb.yml @@ -84,6 +84,7 @@ - name: Install the cron job that manages log files rotation template: src=mongo_log_rotate.sh.j2 dest=/etc/cron.daily/mongo_log_rotate owner=root group=root mode=0555 + when: not mongodb_systemlog_external_logrotate tags: [ 'mongodb', 'mongo_logrotate' ] - name: Ensure mongodb is started and enabled diff --git a/mongodb-org-3.2/templates/mongod-3.2.conf.j2 b/mongodb-org-3.2/templates/mongod-3.2.conf.j2 index 030dd987..a777e6b8 100644 --- a/mongodb-org-3.2/templates/mongod-3.2.conf.j2 +++ b/mongodb-org-3.2/templates/mongod-3.2.conf.j2 @@ -16,10 +16,14 @@ storage: # where to write logging data. systemLog: destination: {{ mongodb_systemlog_destination }} - logAppend: {{ mongodb_systemlog_logappend }} path: {{ mongodb_logpath }} - logRotate: {{ mongodb_systemlog_logrotate }} - +{% if mongodb_systemlog_external_logrotate %} + logRotate: rename + logAppend: false +{% else %} + logRotate: reopen + logAppend: true +{% endif %} # network interfaces net: port: {{ mongodb_tcp_port }} diff --git a/mongodb-org-3/defaults/main.yml b/mongodb-org-3/defaults/main.yml index 2f0c35ae..851a2b3c 100644 --- a/mongodb-org-3/defaults/main.yml +++ b/mongodb-org-3/defaults/main.yml @@ -14,7 +14,6 @@ mongodb_logdir: /var/log/mongodb mongodb_log_file: mongod.log mongodb_logpath: '{{ mongodb_logdir }}/{{ mongodb_log_file }}' mongodb_dbpath: /var/lib/mongodb -mongodb_log_retain_days: 7 mongodb_directoryperdb: 'false' mongodb_conf_file: /etc/mongod.conf mongodb_daemon: /usr/bin/mongod @@ -25,12 +24,14 @@ mongodb_allowed_hosts: mongodb_storage_engine: wiredTiger +# Do not change the default. We do not manage a logrotate configuration yet +mongodb_systemlog_external_logrotate: False mongodb_systemlog_destination: file +mongodb_log_retain_days: 7 +# Not used anymore inside the template. Now we use different values based on mongodb_systemlog_external_logrotate mongodb_systemlog_logappend: 'true' mongodb_systemlog_logrotate: reopen - - mongodb_cluster_enabled: False mongodb_replicaset: storagedev mongodb_replica_keyfile: '{{ mongodb_dbpath }}/replica_keyfile' diff --git a/mongodb-org-3/tasks/mongodb.yml b/mongodb-org-3/tasks/mongodb.yml index 713425cf..2524e6d3 100644 --- a/mongodb-org-3/tasks/mongodb.yml +++ b/mongodb-org-3/tasks/mongodb.yml @@ -53,6 +53,7 @@ - name: Install the cron job that manages log files rotation template: src=mongo_log_rotate.sh.j2 dest=/etc/cron.daily/mongo_log_rotate owner=root group=root mode=0555 + when: not mongodb_systemlog_external_logrotate tags: [ 'mongodb', 'mongo_logrotate' ] - name: Ensure mongodb is started diff --git a/mongodb-org-3/templates/mongod-3.0.conf.j2 b/mongodb-org-3/templates/mongod-3.0.conf.j2 index 871adc92..48e45f17 100644 --- a/mongodb-org-3/templates/mongod-3.0.conf.j2 +++ b/mongodb-org-3/templates/mongod-3.0.conf.j2 @@ -16,10 +16,14 @@ storage: # where to write logging data. systemLog: destination: {{ mongodb_systemlog_destination }} - logAppend: {{ mongodb_systemlog_logappend }} path: {{ mongodb_logpath }} - logRotate: {{ mongodb_systemlog_logrotate }} - +{% if mongodb_systemlog_external_logrotate %} + logRotate: rename + logAppend: false +{% else %} + logRotate: reopen + logAppend: true +{% endif %} # network interfaces net: port: {{ mongodb_tcp_port }}