From 76864f226eefa7b69c2e331f59c82ba7a6112b51 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 24 Oct 2019 15:36:51 +0200 Subject: [PATCH 1/2] WIP mongodb: compatibility with Debian 10 --- CHANGELOG.md | 2 +- mongodb/tasks/main_buster.yml | 30 ++++++++---------- mongodb/templates/logrotate_buster.j2 | 15 +++++++++ mongodb/templates/mongodb_buster.conf.j2 | 39 ++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 18 deletions(-) create mode 100644 mongodb/templates/logrotate_buster.j2 create mode 100644 mongodb/templates/mongodb_buster.conf.j2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f594183..c86f384a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ The **patch** part changes incrementally at each release. * generate-ldif: support MariaDB 10.3 * haproxy: add a variable to keep the existing configuration * listupgrade: install old-kernel-autoremoval script -* mongodb: still incompatible with Debian 10 +* mongodb: compatibility with Debian 10 * mysql: activate binary logs by specifying log_bin path * mysql: specify a custom server_id * mysql-oracle: backport tasks from mysql role diff --git a/mongodb/tasks/main_buster.yml b/mongodb/tasks/main_buster.yml index 7fb73251..bf2e339a 100644 --- a/mongodb/tasks/main_buster.yml +++ b/mongodb/tasks/main_buster.yml @@ -1,9 +1,5 @@ --- -- name: MongoDB is incompatible with Debian 10 - fail: - msg: MongoDB is incompatible with Debian 10 - - name: MongoDB public GPG Key apt_key: # url: https://www.mongodb.org/static/pgp/server-4.2.asc @@ -27,16 +23,16 @@ name: python-pymongo state: present -# - name: Custom configuration -# template: -# src: mongod_buster.conf.j2 -# dest: "/etc/mongod.conf" -# force: "{{ mongodb_force_config | bool | ternary('yes', 'no') }}" -# notify: restart mongod -# -# - name: Configure logrotate -# template: -# src: logrotate_buster.j2 -# dest: /etc/logrotate.d/mongodb -# force: yes -# backup: no +- name: Custom configuration + template: + src: mongod_buster.conf.j2 + dest: "/etc/mongod.conf" + force: "{{ mongodb_force_config | bool | ternary('yes', 'no') }}" + notify: restart mongod + +- name: Configure logrotate + template: + src: logrotate_buster.j2 + dest: /etc/logrotate.d/mongodb + force: yes + backup: no diff --git a/mongodb/templates/logrotate_buster.j2 b/mongodb/templates/logrotate_buster.j2 new file mode 100644 index 00000000..fe5926a0 --- /dev/null +++ b/mongodb/templates/logrotate_buster.j2 @@ -0,0 +1,15 @@ +# {{ ansible_managed }} + +/var/log/mongodb/mongodb.log { + daily + missingok + rotate 365 + dateext + compress + delaycompress + notifempty + sharedscripts + postrotate + pidof mongod | xargs kill -USR1 + endscript +} diff --git a/mongodb/templates/mongodb_buster.conf.j2 b/mongodb/templates/mongodb_buster.conf.j2 new file mode 100644 index 00000000..b61479bd --- /dev/null +++ b/mongodb/templates/mongodb_buster.conf.j2 @@ -0,0 +1,39 @@ +# mongodb.conf - {{ ansible_managed }} + +# for documentation of all options, see: +# http://docs.mongodb.org/manual/reference/configuration-options/ + +# Where and how to store data. +storage: + dbPath: /var/lib/mongodb + journal: + enabled: true +# engine: +# mmapv1: +# wiredTiger: + +# where to write logging data. +systemLog: + destination: file + logRotate: reopen + logAppend: true + path: /var/log/mongodb/mongodb.log + +# network interfaces +net: + port: {{ mongodb_port }} + bindIp: {{ mongodb_bind }} + +#security: + +#operationProfiling: + +#replication: + +#sharding: + +## Enterprise-Only Options: + +#auditLog: + +#snmp: From 5eff84bc073b8cf2855bd56ffc43a7c9093c9188 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 24 Oct 2019 16:43:24 +0200 Subject: [PATCH 2/2] mongodb: fix systemd service --- mongodb/tasks/main_buster.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mongodb/tasks/main_buster.yml b/mongodb/tasks/main_buster.yml index bf2e339a..b04047e0 100644 --- a/mongodb/tasks/main_buster.yml +++ b/mongodb/tasks/main_buster.yml @@ -7,7 +7,7 @@ - name: enable APT sources list apt_repository: - repo: deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.2 main + repo: deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main state: present filename: mongodb-org-4.2 update_cache: yes @@ -17,6 +17,14 @@ name: mongodb-org update_cache: yes state: present + register: _mongodb_install_package + +- name: MongoDB service in enabled and started + systemd: + name: mongod + enabled: yes + state: started + when: _mongodb_install_package.changed - name: install dependency for monitoring apt: @@ -25,7 +33,7 @@ - name: Custom configuration template: - src: mongod_buster.conf.j2 + src: mongodb_buster.conf.j2 dest: "/etc/mongod.conf" force: "{{ mongodb_force_config | bool | ternary('yes', 'no') }}" notify: restart mongod