Skip to content

Commit

Permalink
feat: add compat for latest mongodb version
Browse files Browse the repository at this point in the history
  • Loading branch information
tboerger committed Oct 26, 2024
1 parent 5a7c4be commit fc15e02
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
13 changes: 11 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
# @var mongodb_server_version:description: Version of MongoDB that gets installed
mongodb_server_version: "8.0"

# @var mongodb_packages:description: List of packages to install for mongodb
mongodb_packages:
- mongodb-org
- numactl
- python3-pip
- python3-pymongo

# @var mongodb_server_version:description: Version of pymongo installed via pip
# renovate: datasource=pypi depName=pymongo
mongodb_pymongo_version: 3.12.3
mongodb_pymongo_version: False

# @var mongodb_limit_files:description: Limit for open files for the mongod service
mongodb_limit_files: 1048576
Expand Down Expand Up @@ -233,6 +239,9 @@ mongodb_user: mongodb
# @var mongodb_keyring:description: Path for the repository keyring
mongodb_keyring: /usr/share/keyrings/mongodb-{{ mongodb_server_version }}-archive-keyring.gpg

# @var mongodb_numa_enabled:description: Enable if the system supports NUMA policies
mongodb_numa_enabled: True

# @var mongodb_backup_enabled:description: Enable or disable the backup script
mongodb_backup_enabled: False

Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Converge
hosts: all
vars:
mongodb_server_version: "6.0"
mongodb_numa_enabled: False
roles:
- role: rolehippie.mongodb

Expand Down
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@
- mongodb

- name: Install required packages
loop:
- mongodb-org
- numactl
- python3-pip
loop: "{{ mongodb_packages }}"
ansible.builtin.package:
name: "{{ item }}"
state: present
tags:
- mongodb

- name: Install pymongo pip
when:
- mongodb_pymongo_version | default(False)
ansible.builtin.pip:
name: pymongo
state: "{{ mongodb_pymongo_version is defined | ternary('present', 'latest') }}"
version: "{{ mongodb_pymongo_version | default(omit) }}"
break_system_packages: True
tags:
- mongodb

Expand Down
4 changes: 3 additions & 1 deletion templates/config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ storage:
dbPath: {{ mongodb_storage_path }}
directoryPerDB: {{ mongodb_storage_dirperdb | lower }}
engine: {{ mongodb_storage_engine }}
{% if mongodb_server_version is version("6.1", "<") %}
journal:
enabled: {{ mongodb_storage_journal_enabled | lower }}
{% endif %}
{% if mongodb_storage_engine == 'mmapv1' %}
mmapv1:
quota:
Expand Down Expand Up @@ -68,7 +70,7 @@ systemLog:
operationProfiling:
slowOpThresholdMs: {{ mongodb_operation_profiling_slow_op_threshold_ms }}
mode: {{ mongodb_operation_profiling_mode }}
{% if mongodb_server_version is version("4.0", ">=") %}
{% if mongodb_server_version is version("4.0", ">=") and mongodb_server_version is version("5.0", "<") %}

cloud:
monitoring:
Expand Down
2 changes: 1 addition & 1 deletion templates/service.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LimitNPROC={{ mongodb_limit_procs }}
TasksAccounting=false

EnvironmentFile=/etc/default/mongod
ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod --config /etc/mongod.conf
ExecStart={% if mongodb_numa_enabled %}/usr/bin/numactl --interleave=all {% endif %}/usr/bin/mongod --config /etc/mongod.conf
PIDFile={{ mongodb_pidfile_path }}

[Install]
Expand Down

0 comments on commit fc15e02

Please sign in to comment.