Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ mongodb_cloud_monitoring_free_state: "runtime"
mongodb_replication_replset: "" # Enable replication
mongodb_replication_replindexprefetch: "all" # specify index prefetching behavior (if secondary) [none|_id_only|all]
mongodb_replication_oplogsize: 1024 # specifies a maximum size in megabytes for the replication operation log
mongodb_enable_majority_read_concern: false

# MMS Agent
mongodb_mms_agent_pkg: https://cloud.mongodb.com/download/agent/monitoring/mongodb-mms-monitoring-agent_7.2.0.488-1_amd64.ubuntu1604.deb
Expand Down
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

- name: mongodb restart
service:
name: "{{ mongodb_daemon_name }}"
name: "{{ mongodb_daemon_name }}@{{ mongodb_instance_name }}"
state: restarted
when: mongodb_manage_service | bool

Expand Down
4 changes: 2 additions & 2 deletions tasks/auth_initialization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Use different mongod.conf for auth initialization
template:
src: mongod_init.conf.j2
dest: /etc/mongod.conf
dest: "{{ mongodb_conf_file }}"
owner: root
group: root
mode: 0644
Expand Down Expand Up @@ -64,7 +64,7 @@
- name: Move back mongod.conf
template:
src: mongod.conf.j2
dest: /etc/mongod.conf
dest: "{{ mongodb_conf_file }}"
owner: root
group: root
mode: 0644
Expand Down
2 changes: 1 addition & 1 deletion tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
- name: Configure mongodb
template:
src: mongod.conf.j2
dest: /etc/mongod.conf
dest: "{{ mongodb_conf_file }}"
backup: true
owner: root
group: root
Expand Down
4 changes: 3 additions & 1 deletion tasks/disable_transparent_hugepages.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
---
- name: Create disable transparent hugepages systemd service file
template:
src: "{{ item }}"
src: "{{ template_name }}"
dest: /etc/systemd/system/disable-transparent-hugepages.service
owner: root
group: root
mode: 0644
with_first_found:
- "disable-transparent-hugepages.{{ ansible_distribution | lower }}.service.j2"
- "disable-transparent-hugepages.{{ ansible_os_family | lower }}.service.j2"
loop_control:
loop_var: template_name
notify: "run disable-transparent-hugepages"
when:
- ansible_service_mgr == "systemd"
Expand Down
6 changes: 3 additions & 3 deletions tasks/install.debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
- name: Add systemd configuration if present
template:
src: mongodb.service.j2
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
dest: "/lib/systemd/system/{{ mongodb_daemon_name }}@.service"
owner: root
group: root
mode: '0644'
Expand All @@ -74,8 +74,8 @@

- name: Add symlink for systemd
file:
src: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
dest: "/etc/systemd/system/multi-user.target.wants/{{mongodb_daemon_name}}.service"
src: "/lib/systemd/system/{{ mongodb_daemon_name }}@.service"
dest: "/etc/systemd/system/multi-user.target.wants/{{mongodb_daemon_name}}@{{ mongodb_instance_name }}.service"
state: link
when:
- ansible_service_mgr == "systemd"
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@

- name: service started
service:
name: "{{ mongodb_daemon_name }}"
name: "{{ mongodb_daemon_name }}@{{ mongodb_instance_name }}"
state: started
enabled: yes

Expand Down
1 change: 1 addition & 0 deletions templates/mongod.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ processManagement:
replication:
oplogSizeMB: {{ mongodb_replication_oplogsize | int }}
replSetName: {{ mongodb_replication_replset }}
enableMajorityReadConcern: {{ mongodb_enable_majority_read_concern | to_nice_json }}
{% if mongodb_storage_engine == 'mmapv1' -%}
secondaryIndexPrefetch: {{ mongodb_replication_replindexprefetch }}
{% endif %}
Expand Down
6 changes: 3 additions & 3 deletions templates/mongodb.service.j2
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# {{ ansible_managed }}
[Unit]
Description=An object/document-oriented database
Description=MongoDB instance %i
Documentation=man:mongod(1)

[Service]
User={{ mongodb_user }}
{% if mongodb_use_numa | bool %}
ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod --config /etc/mongod.conf
ExecStart=/usr/bin/numactl --interleave=all /usr/bin/mongod --config "/etc/{{ mongodb_daemon_name }}.%i.conf"
{% else %}
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
ExecStart=/usr/bin/mongod --config "/etc/{{ mongodb_daemon_name }}.%i.conf"
{% endif %}
# file size
LimitFSIZE=infinity
Expand Down