Skip to content

Commit 2dec490

Browse files
authored
Merge pull request #70 from davidcaste/fix-again-systemd
Fix (again) Systemd support
2 parents a830a58 + 40c3ced commit 2dec490

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

handlers/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
- name: reload systemd
1616
shell: systemctl daemon-reload
17-
when: systemd.stat.exists == true and mongodb_manage_service
17+
when: mongodb_is_systemd and mongodb_manage_service
1818

1919
- name: restart sysfsutils
2020
service: name=sysfsutils state=restarted

tasks/install.deb.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,39 @@
88
changed_when: false
99
always_run: yes # side-effect free, so it can be run in check-mode as well
1010

11+
- name: Establish some role-related facts
12+
set_fact:
13+
mongodb_is_systemd: "{{ sbin_init.stat.islnk is defined and sbin_init.stat.islnk }}"
14+
mongodb_major_version: "{{ mongodb_version[0:3] }}"
15+
1116
- name: Add systemd configuration if present
1217
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0640
13-
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
18+
when: mongodb_is_systemd
1419

1520
- name: Add symlink for systemd
1621
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
17-
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
22+
when: mongodb_is_systemd
1823
notify: reload systemd
1924

2025
- meta: flush_handlers
21-
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
26+
when: mongodb_is_systemd
2227

2328
- name: Add APT key
2429
apt_key:
2530
keyserver: "{{mongodb_apt_keyserver}}"
2631
id: "{{mongodb_apt_key_id}}"
2732
when: mongodb_package == 'mongodb-org'
28-
33+
2934
- name: Fail when used wrong mongodb_version variable
3035
fail:
3136
msg: "mongodb_version variable should be '2.6', '3.0' or '3.2'"
3237
when: (mongodb_package == 'mongodb-org' and
3338
(mongodb_version is not defined
34-
or mongodb_repository[item] is not defined))
35-
with_items: "{{ mongodb_version[0:3] }}"
36-
39+
or mongodb_repository[mongodb_major_version] is not defined))
40+
3741
- name: Add APT repository
3842
apt_repository: repo="{{ mongodb_repository[item] }}" update_cache=yes
39-
with_items: "{{ mongodb_version[0:3] }}"
43+
with_items: "{{ mongodb_major_version }}"
4044
when: mongodb_package == 'mongodb-org'
4145

4246
- name: Install MongoDB package
@@ -48,7 +52,7 @@
4852
- name: reload systemd
4953
shell: systemctl daemon-reload
5054
changed_when: false
51-
when: sbin_init.stat.islnk is defined and sbin_init.stat.islnk
55+
when: mongodb_is_systemd
5256

5357
- name: Install PyMongo package
5458
apt: pkg=python-pymongo state=latest

templates/mongod.conf.j2

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ replication:
1919
secondaryIndexPrefetch: {{ mongodb_replication_replindexprefetch }}
2020
{% endif %}
2121
{% endif %}
22-
22+
2323
security:
2424
authorization: {{ mongodb_security_authorization }}
2525
{% if mongodb_replication_replset and mongodb_security_authorization == 'enabled' -%}
@@ -28,7 +28,7 @@ security:
2828

2929
storage:
3030
dbPath: {{ mongodb_storage_dbpath }}
31-
{% if mongodb_version[0:3]|float >= 3.0 -%}
31+
{% if mongodb_major_version|float >= 3.0 -%}
3232
engine: {{ mongodb_storage_engine }}
3333
{% endif -%}
3434
journal:
@@ -40,7 +40,7 @@ storage:
4040
maxFilesPerDB: {{ mongodb_storage_quota_maxfiles }}
4141
smallFiles: {{ mongodb_storage_smallfiles | to_nice_json }}
4242
{% endif -%}
43-
{% if mongodb_version[0:3] == '2.6' -%}
43+
{% if mongodb_major_version == '2.6' -%}
4444
quota:
4545
enforced: {{ mongodb_storage_quota_enforced | to_nice_json }}
4646
maxFilesPerDB: {{ mongodb_storage_quota_maxfiles }}
@@ -52,4 +52,3 @@ systemLog:
5252
destination: {{ mongodb_systemlog_destination }}
5353
logAppend: {{ mongodb_systemlog_logappend | to_nice_json }}
5454
path: {{ mongodb_systemlog_path }}
55-

templates/mongod_init.conf.j2

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ net:
1010

1111
processManagement:
1212
fork: {{ mongodb_processmanagement_fork | to_nice_json }}
13-
13+
1414
security:
1515
authorization: 'disabled'
1616

1717
storage:
1818
dbPath: {{ mongodb_storage_dbpath }}
19-
{% if mongodb_version[0:3]|float >= 3.0 -%}
19+
{% if mongodb_major_version|float >= 3.0 -%}
2020
engine: {{ mongodb_storage_engine }}
2121
{% endif -%}
2222
journal:
@@ -28,7 +28,7 @@ storage:
2828
maxFilesPerDB: {{ mongodb_storage_quota_maxfiles }}
2929
smallFiles: {{ mongodb_storage_smallfiles | to_nice_json }}
3030
{% endif -%}
31-
{% if mongodb_version[0:3] == '2.6' -%}
31+
{% if mongodb_major_version == '2.6' -%}
3232
quota:
3333
enforced: {{ mongodb_storage_quota_enforced | to_nice_json }}
3434
maxFilesPerDB: {{ mongodb_storage_quota_maxfiles }}

0 commit comments

Comments
 (0)