Skip to content

Commit bc79032

Browse files
committed
fixing systemd issue
Updating systemd detection by getting PID 1 command line instead of checking systemd folder. This to avoid issues with Docker for example.
1 parent ede8b4c commit bc79032

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

tasks/configure.yml

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

1919
- name: wait MongoDB port is listening
2020
wait_for: host="{{ mongodb_conf_bind_ip }}"port="{{ mongodb_conf_port }}" delay=10 timeout=60 state=started
21-
#when: systemd.stat.exists == true
21+
when: "'systemd' in systemd.stdout"
2222

2323
- include: auth_initialization.yml
2424
when: mongodb_conf_auth

tasks/install.deb.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
- include_vars: "{{ansible_distribution}}.yml"
44

5-
- name: Check if systemd is present
6-
stat: path=/bin/systemd
5+
- name: Check if running on systemd
6+
command: cat /proc/1/cmdline
77
register: systemd
88

99
- name: Add systemd configuration if present
1010
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0640
11-
when: systemd.stat.exists == true
11+
when: "'systemd' in systemd.stdout"
1212

1313
- name: Add symlink for systemd
1414
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
15-
when: systemd.stat.exists == true
15+
when: "'systemd' in systemd.stdout"
1616
notify: reload systemd
1717

1818
- meta: flush_handlers
19-
when: systemd.stat.exists == true
19+
when: "'systemd' in systemd.stdout"
2020

2121
- name: Add APT key
2222
apt_key: url=http://docs.mongodb.org/10gen-gpg-key.asc id=7F0CEB10
@@ -32,7 +32,7 @@
3232
- name: reload systemd
3333
shell: systemctl daemon-reload
3434
changed_when: false
35-
when: systemd.stat.exists == true
35+
when: "'systemd' in systemd.stdout"
3636

3737
- name: Install additional packages
3838
apt: pkg={{item}}

tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22

33
- include: install.deb.yml
44
when: ansible_os_family == 'Debian'
5+
tags: [mongodb]
56

67
- include: configure.yml
8+
tags: [mongodb]
79

810
- include: replication.yml
911
when: mongodb_conf_replSet != ""
12+
tags: [mongodb]
1013

1114
- include: mms-agent.yml
1215
when: mongodb_mms_api_key != ""
16+
tags: [mongodb]

0 commit comments

Comments
 (0)