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 }}"