Compare commits

...

8 Commits

4 changed files with 26 additions and 21 deletions

View File

@ -49,9 +49,9 @@ mongodb_directoryperdb: 'false'
mongodb_conf_file: /etc/mongod.conf
mongodb_daemon: /usr/bin/mongod
mongod_additional_options: ""
mongodb_allowed_hosts:
- 127.0.0.1/8
- '{{ ansible_default_ipv4.address }}/32'
# mongodb_allowed_hosts:
# - 127.0.0.1/8
# - '{{ ansible_default_ipv4.address }}/32'
mongodb_storage_engine: wiredTiger
@ -81,10 +81,11 @@ mongodb_cluster_enabled: False
mongodb_authorization_enabled: False
mongodb_replicaset: storagedev
mongodb_replica_keyfile: '{{ mongodb_dbpath }}/replica_keyfile'
mongodb_oplog_size: 2000
# Prometheus metrics
mongodb_prometheus_exporter_enabled: False
mongodb_prometheus_exporter_version: '0.30.0'
mongodb_prometheus_exporter_enabled: false
mongodb_prometheus_exporter_version: '0.39.0'
mongodb_prometheus_exporter_dir: 'mongodb_exporter-{{ mongodb_prometheus_exporter_version }}.linux-amd64'
mongodb_prometheus_exporter_file: '{{ mongodb_prometheus_exporter_dir }}.tar.gz'
mongodb_prometheus_exporter_download_url: 'https://github.com/percona/mongodb_exporter/releases/download/v{{ mongodb_prometheus_exporter_version }}/{{ mongodb_prometheus_exporter_file }}'

View File

@ -68,13 +68,3 @@
when: mongodb_prometheus_exporter_enabled
tags: [ 'mongodb', 'prometheus', 'mongodb_prometheus' ]
- name: No mongodb exporter
block:
- name: Ensure that prometheus mongodb_exporter is stopped and disabled
ansible.builtin.service:
name: mongodb_exporter
state: stopped
enabled: no
when: not mongodb_prometheus_exporter_enabled
tags: [ 'mongodb', 'prometheus', 'mongodb_prometheus' ]

View File

@ -44,7 +44,7 @@ security:
keyFile: {{ mongodb_replica_keyfile }}
replication:
oplogSizeMB: 2000
oplogSizeMB: {{ mongodb_oplog_size }}
replSetName: {{ mongodb_replicaset }}
enableMajorityReadConcern: false
{% endif %}

View File

@ -12,17 +12,31 @@ echo "$DATE" > $LE_LOG_DIR/mongodb.log
[ ! -d $MONGODB_CERTDIR ] && mkdir $MONGODB_CERTDIR
cat ${LE_CERTS_DIR}/{fullchain,privkey} > ${MONGODB_CERTFILE}.new
cmp ${MONGODB_CERTFILE}.new ${MONGODB_CERTFILE} 2>/dev/null
if [ $? -eq 0 ] ; then
echo "The certificate is up to date" >> $LE_LOG_DIR/mongodb.log
rm -f ${MONGODB_CERTFILE}.new
exit 0
fi
echo "Building the new certificate file" >> $LE_LOG_DIR/mongodb.log
cat ${LE_CERTS_DIR}/{cert,privkey} > ${MONGODB_CERTFILE}
/bin/mv -f ${MONGODB_CERTFILE}.new ${MONGODB_CERTFILE}
chmod 440 ${MONGODB_CERTFILE}
chgrp mongodb ${MONGODB_CERTFILE}
{% if mongodb_ssl_enabled %}
echo "Reload the mongod service" >> "$LE_LOG_DIR/mongodb.log"
echo "Restart the mongod service, reload is not supported" >> "$LE_LOG_DIR/mongodb.log"
{% if mongodb_install_from_external_repo %}
service mongod stop >> "$LE_LOG_DIR/mongodb.log" 2>&1
sleep 10
service mongod start >> "$LE_LOG_DIR/mongodb.log" 2>&1
if [ -x /sbin/stop ] && [ -f /etc/init/mongod.conf ] ; then
/sbin/stop mongod >> "$LE_LOG_DIR/mongodb.log" 2>&1
sleep 10
/sbin/start mongod >> "$LE_LOG_DIR/mongodb.log" 2>&1
else
service mongod stop >> "$LE_LOG_DIR/mongodb.log" 2>&1
sleep 10
service mongod start >> "$LE_LOG_DIR/mongodb.log" 2>&1
fi
{% else %}
systemctl stop mongodb >> "$LE_LOG_DIR/mongodb.log" 2>&1
sleep 10