From 9bb16485652a6478090d556d65577b4ea6fd388b Mon Sep 17 00:00:00 2001 From: Deimosfr Date: Sun, 28 Jun 2015 21:54:04 +0200 Subject: [PATCH] fix issue with unmanaged service with latest update, a mongodb restart couldn't work properly. New checks have been added to fix the issue --- tasks/auth_initialization.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tasks/auth_initialization.yml b/tasks/auth_initialization.yml index c48d475..f1668be 100644 --- a/tasks/auth_initialization.yml +++ b/tasks/auth_initialization.yml @@ -4,6 +4,17 @@ - name: Restart mongodb service service: name={{ mongodb_daemon_name }} state=restarted + when: mongodb_manage_service + +- name: get pid of mongodb for non daemon mode + shell: "pidof mongod" + register: pidof_mongod + when: mongodb_manage_service == false + ignore_errors: yes + +- name: start mongodb daemon + shell: "LC_ALL=C /usr/bin/mongod --config /etc/mongod.conf --fork" + when: mongodb_manage_service == false and pidof_mongod.rc == 1 - name: create administrative user siteUserAdmin mongodb_user: @@ -52,3 +63,8 @@ - name: Restart mongodb service service: name={{ mongodb_daemon_name }} state=restarted + when: mongodb_manage_service + +- name: stop mongodb if was not started + shell: "kill {{ pidof_mongod.stdout }}" + when: mongodb_manage_service == false and pidof_mongod.rc == 0