From 4f9b946b2afe3f2eaa179beaab8d5929eed19270 Mon Sep 17 00:00:00 2001 From: Drew Freiberger Date: Wed, 31 Oct 2018 17:03:06 -0500 Subject: Ensure bind_ip=all listens externally on bionic Mongodb by default on bionic only listens on localhost, which means no relations to mongodb can connect to the database by default when using charm default configs of bind_ip=all and replicaset_master=auto. This issue was mitigated for HA deployments of mongodb in commit 7b2828638b3dad83776fef60b0dc96825ec4e10e, but did not solve client connectivity. This patch resolves the issue for HA and non HA deploys. Closes-Bug: #1800208 --- hooks/hooks.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hooks/hooks.py b/hooks/hooks.py index ec4adfb..93d8329 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -275,7 +275,10 @@ def mongodb_conf(config_data=None): # bind_ip if config_data['bind_ip'] != "all": config.append("bind_ip = %s" % config_data['bind_ip']) - config.append("") + elif is_bionic_or_greater(): + config_data['bind_ip'] = '0.0.0.0' + config.append("") + # port config.append("port = %d" % config_data['port']) @@ -573,10 +576,6 @@ def enable_replset(replicaset_name=None): current_config = get_current_mongo_config() config_data = dict(config()) - if is_bionic_or_greater(): - if config_data['bind_ip'] == "all": - config_data['bind_ip'] = '0.0.0.0' - if 'replSet' in current_config and \ current_config['replSet'] == config_data['replicaset']: juju_log('enable_replset: replica set is already enabled', -- cgit v1.2.3