Skip to content

Commit 8687cdb

Browse files
committed
Merge pull request #15 from deimosfr/master
fixing creation user fail when not managing service and typo
2 parents 8f1bb3f + c440999 commit 8687cdb

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mongodb_package: mongodb-org
1515
mongodb_force_wait_for_port: false # When not forced, the role will wait for mongod port to become available only with systemd
1616
mongodb_pymongo_from_pip: false # Install latest PyMongo via PIP or package manager
1717

18-
mongodb_manager_service: true
18+
mongodb_manage_service: true
1919

2020
mongodb_user: mongodb
2121
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mongodb_package: mongodb-org
44
mongodb_force_wait_for_port: false
55
mongodb_pymongo_from_pip: false # Install latest PyMongo via PIP or package manager
66

7-
mongodb_manager_service: true
7+
mongodb_manage_service: true
88

99
mongodb_user: mongodb
1010
mongodb_daemon_name: "{{ 'mongod' if ('mongodb-org' in mongodb_package) else 'mongodb' }}"

handlers/main.yml

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

33
- name: mongodb reload
44
service: name={{ mongodb_daemon_name }} state=reloaded
5-
when: mongodb_manager_service
5+
when: mongodb_manage_service
66

77
- name: mongodb restart
88
service: name={{ mongodb_daemon_name }} state=restarted
9-
when: mongodb_manager_service
9+
when: mongodb_manage_service
1010

1111
- name: mongodb-mms-automation-agent restart
1212
service: name=mongodb-mms-automation-agent state=restarted
13-
when: mongodb_manager_service
13+
when: mongodb_manage_service
1414

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

tasks/configure.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
23
- name: Register default MongoDB listen IP
34
set_fact: mongodb_listen_ip=127.0.0.1
45
when: ansible_local.mongodb.mongodb.mongodb_listen_ip is undefined
@@ -7,7 +8,6 @@
78
set_fact: mongodb_listen_ip={{ ansible_local.mongodb.mongodb.mongodb_listen_ip }}
89
when: ansible_local.mongodb.mongodb.mongodb_listen_ip is defined
910

10-
1111
- name: Create keyFile
1212
copy:
1313
dest: "{{ mongodb_conf_keyFile }}"
@@ -23,7 +23,16 @@
2323

2424
- name: ensure mongodb started and enabled
2525
service: name={{ mongodb_daemon_name }} state=started enabled=yes
26-
when: mongodb_manager_service
26+
when: mongodb_manage_service
27+
28+
- name: get pid of mongod
29+
command: pidof mongod
30+
register: mongod_pid
31+
ignore_errors: True
32+
33+
- name: temporary start mongod if not started
34+
command: '/usr/bin/mongod --config /etc/mongod.conf --fork'
35+
when: mongod_pid.rc != 0
2736

2837
- name: wait MongoDB port is listening
2938
wait_for: host="{{ mongodb_listen_ip }}" port="{{ mongodb_conf_port }}" delay=10 timeout=60 state=started
@@ -51,6 +60,15 @@
5160
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
5261
register: config_result
5362

63+
- name: get pid of mongod
64+
command: pidof mongod
65+
register: mongod_new_pid
66+
when: mongod_pid.rc != 0
67+
68+
- name: kill temporary mongod if started
69+
command: kill {{ mongod_new_pid.stdout }}
70+
when: mongod_pid.rc != 0
71+
5472
- name: mongodb restart
5573
service: name={{ mongodb_daemon_name }} state=restarted
56-
when: config_result|changed and mongodb_manager_service
74+
when: config_result|changed and mongodb_manage_service

tasks/mms-agent.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
- name: Ensure that the MMS agent is started
1919
service: name=mongodb-mms-automation-agent state=started enabled=yes
20-
when: mongodb_manager_service
20+
when: mongodb_manage_service

0 commit comments

Comments
 (0)