Skip to content

Commit 137e4f1

Browse files
committed
Add flag 'mongodb_manage_systemd_unit' for disable manage systemd unit
file of MongoDB.
1 parent 4632f4b commit 137e4f1

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mongodb_pymongo_from_pip: true # Install latest PyMongo via PIP or package manag
4343
mongodb_pymongo_pip_version: 3.6.1 # Choose PyMong version to install from pip. If not set use latest
4444
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
4545
mongodb_manage_service: true
46+
mongodb_manage_systemd_unit: true
4647

4748
# Disable transparent hugepages on systemd debian based installations
4849
mongodb_disable_transparent_hugepages: false

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ mongodb_pymongo_pip_version: 3.7.1
1515

1616
mongodb_user_update_password: "on_create" # MongoDB user password update default policy
1717
mongodb_manage_service: true
18+
mongodb_manage_systemd_unit: true
1819

1920
mongodb_disable_transparent_hugepages: false
2021

handlers/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
- name: reload systemd
44
systemd:
55
daemon_reload: yes
6-
when: ansible_service_mgr == "systemd" and mongodb_manage_service
6+
when: ansible_service_mgr == "systemd" and mongodb_manage_service | bool
77

88
- name: mongodb reload
99
service:
1010
name: "{{ mongodb_daemon_name }}"
1111
state: reloaded
12-
when: mongodb_manage_service|bool
12+
when: mongodb_manage_service | bool
1313

1414
- name: mongodb restart
1515
service:
1616
name: "{{ mongodb_daemon_name }}"
1717
state: restarted
18-
when: mongodb_manage_service|bool
18+
when: mongodb_manage_service | bool
1919

2020
- name: mongodb-mms-monitoring-agent restart
2121
service:
2222
name: mongodb-mms-monitoring-agent
2323
state: restarted
24-
when: mongodb_manage_service|bool
24+
when: mongodb_manage_service | bool
2525

2626
- name: restart sysfsutils
2727
service:

tasks/install.debian.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,22 @@
5959
state: present
6060

6161
- name: Add systemd configuration if present
62-
copy: src=mongodb.service dest=/lib/systemd/system/{{mongodb_daemon_name}}.service owner=root group=root mode=0644
63-
when: ansible_service_mgr == "systemd"
62+
copy:
63+
src: mongodb.service
64+
dest: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
65+
owner: root
66+
group: root
67+
mode: '0644'
68+
when: ansible_service_mgr == "systemd" and mongodb_manage_systemd_unit | bool
6469
notify:
6570
- reload systemd
6671

6772
- name: Add symlink for systemd
68-
file: src=/lib/systemd/system/{{mongodb_daemon_name}}.service dest=/etc/systemd/system/multi-user.target.wants/{{mongodb_daemon_name}}.service state=link
69-
when: ansible_service_mgr == "systemd"
73+
file:
74+
src: "/lib/systemd/system/{{mongodb_daemon_name}}.service"
75+
dest: "/etc/systemd/system/multi-user.target.wants/{{mongodb_daemon_name}}.service"
76+
state: link
77+
when: ansible_service_mgr == "systemd" and mongodb_manage_systemd_unit | bool
7078
notify:
7179
- reload systemd
7280

0 commit comments

Comments
 (0)