The following script will SSH to a Juju 2.0 controller machine and start a mongo shell. It optionally takes the machine to connect to and the model name (defaulting to machine “0” in the model named “controller”).
That does works, though on Bionic it adds a literal “/usr/lib/juju/mongo*/bin” to PATH if it doesn’t exist. It isn’t a huge deal, as a PATH that doesn’t exist doesn’t match anything.
But inside the agent.conf. I found a non existent apiaddresses. (i restarted the lxd server with the juju controller )
And i can’t find a statepassword in the agent.conf.
There is only a apipassword, oldpassword and a cacert…
juju ssh didn’t work in my case, because i also deleted an lxd-server from the lxd-cluster.
The deleted lxd-server seems to relevant inside of the mongodb-configuration.
Now i will enter the juju-controller with lxc exec ... bash and look, if some of the passwords let me connect to mongo.
Is the mongodb automatically replicated, or did i need to change every instance ?
EDIT: the script at the top of this page has been updated to work with mongo db instances on k8s and should be used instead of the one suggested below.
If you are trying to access a mongodb instance on k8s, the above scripts won’t do the trick for you.
However, this will work (replace kubectl_bin accordingly if not using microk8s via snap):
With Mongodb 4.4 does this script need to be updated to use --tls variants instead of --ssl variants?
It’s relevant because we moved to 4.4 for late revisions of 2.9 and certainly for 3.6.
Testing it out, it seems to not really matter. 4.4 gives the terminal a warning about “please use --tls instead of --ssl” but it still accepts the parameter.
{"t":{"$date":"2025-03-28T19:44:21.867Z"},"s":"W", "c":"CONTROL", "id":23321, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"ssl","preferredName":"tls"}}
{"t":{"$date":"2025-03-28T19:44:21.867Z"},"s":"W", "c":"CONTROL", "id":23321, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"sslAllowInvalidCertificates","preferredName":"tlsAllowInvalidCertificates"}}
As such, using the --ssl might still be better for older versions of 2.9 that might have used mongo 4.0. Surprisingly I tried installing the juju-db 7.3 candidate snap, and it still gave the “please use --tls” warning, but didn’t fail.