From 4fcbaa02ed0be409d32b5608f1a15903926e50ec Mon Sep 17 00:00:00 2001 From: Anatoly Chichikov Date: Sat, 11 Mar 2017 16:38:48 +0300 Subject: [PATCH] Fixed issue with multi-port binding timeouts --- tasks/auth_initialization.yml | 5 +++-- tasks/configure.yml | 8 ++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tasks/auth_initialization.yml b/tasks/auth_initialization.yml index d1fc1481..de7fcdfd 100644 --- a/tasks/auth_initialization.yml +++ b/tasks/auth_initialization.yml @@ -74,8 +74,9 @@ service: name={{ mongodb_daemon_name }} state=restarted when: mongodb_manage_service -- name: wait MongoDB port is listening - wait_for: host="{{ mongodb_net_bindip }}" port="{{ mongodb_net_port }}" delay=5 state=started +- name: Wait MongoDB port is listening + wait_for: host="{{ item }}" port="{{ mongodb_net_port }}" delay=5 state=started + with_items: "{{ mongodb_net_bindip.split(',') | map('replace', '0.0.0.0', '127.0.0.1') | list }}" - name: stop mongodb if was not started shell: "kill {{ pidof_mongod.stdout }}" diff --git a/tasks/configure.yml b/tasks/configure.yml index 33c3fef2..940e94a8 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -50,13 +50,9 @@ - name: Ensure service is started service: name={{ mongodb_daemon_name }} state=started -- name: Set fact about wait_for host address - set_fact: - wait_for_host: 127.0.0.1 - when: mongodb_net_bindip == "0.0.0.0" - - name: Wait when mongodb is started wait_for: - host: "{{ wait_for_host | default(mongodb_net_bindip) }}" + host: "{{ item }}" port: "{{ mongodb_net_port }}" timeout: 120 + with_items: "{{ mongodb_net_bindip.split(',') | map('replace', '0.0.0.0', '127.0.0.1') | list }}"