ansible-role-mongodb
ansible-role-mongodb copied to clipboard
Can't connect using mongo from vagrant instance.
I've validated I can telnet to the port I've forwarded from vagrant (localhost:27018) but the mongo client hangs trying to connect using mongo --host 127.0.0.1 --port 27018. This is also true using mongohub.
Vagrantfile port forward
config.vm.network "forwarded_port", guest: 27017, host: 27018
On parent host:
MongoDB shell version v3.6.5
connecting to: mongodb://127.0.0.1:27018/
Inside vagrant vm:
[root@localhost vagrant]# mongo --host 127.0.0.1 --port 27017
MongoDB shell version v3.6.5
connecting to: mongodb://127.0.0.1:27017/
MongoDB server version: 3.6.5
Welcome to the MongoDB shell.
For interactive help, type "help".
Here's my vars, I'm assuming mongodb_security_authorization: "disabled" is the relevant bits to allow unauthorized remote access.
The vars, run against Centos6 vm:
vars:
mongodb_package: mongodb-org
mongodb_version: "3.6"
mongodb_pymongo_from_pip: true
mongodb_user_update_password: "on_create"
mongodb_manage_service: true
mongodb_net_bindip: 127.0.0.1
mongodb_net_http_enabled: false
mongodb_net_ipv6: false
mongodb_net_maxconns: 65536
mongodb_net_port: 27017
mongodb_processmanagement_fork: false
mongodb_security_authorization: "disabled"
mongodb_storage_dbpath: /var/lib/mongo
mongodb_storage_engine: mmapv1
mongodb_storage_quota_enforced: false
mongodb_storage_quota_maxfiles: 8
mongodb_storage_smallfiles: true
mongodb_storage_journal_enabled: true
mongodb_storage_prealloc: true
mongodb_systemlog_destination: "file"
mongodb_systemlog_logappend: true
mongodb_systemlog_path: /var/log/mongodb/{{ mongodb_daemon_name }}.log
mongodb_replication_replset: xxx
mongodb_replication_replindexprefetch: "all"
mongodb_replication_oplogsize: 1024
mongodb_set_parameters: { "enableLocalhostAuthBypass": "true", "authenticationMechanisms": "SCRAM-SHA-1,MONGODB-CR" }
mongodb_mms_agent_pkg: https://cloud.mongodb.com/download/agent/automation/mongodb-mms-automation-agent-manager-latest.x86_64.rpm
mongodb_mms_group_id: "xxx"
mongodb_mms_api_key: "xxx"
mongodb_mms_base_url: https://mms.mongodb.com
mongodb_logrotate: true
mongodb_logrotate_options:
- compress
- copytruncate
- daily
- dateext
- rotate 7
- size 10M
mongodb_user_admin_name: useradmin
mongodb_user_admin_password: "xxx"
mongodb_root_admin_name: root
mongodb_root_admin_password: "xxx"
I am also facing same issue. I provisioned MongoDB using this ansible role on an AWS EC2 instance, I can ssh into the EC2 instance and see that MongoDB is up and running. But when I try to remotely connect from my localhost using mongo mongodb://[ip-address]:27017 I am getting the follow error:
MongoDB shell version v4.2.6
connecting to: mongodb://[ip-address]:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-05-05T11:15:42.527+0530 E QUERY [js] Error: couldn't connect to server [ip-address]:27017, connection attempt failed: SocketException: Error connecting to [ip-address]:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-05-05T11:15:42.530+0530 F - [main] exception: connect failed
2020-05-05T11:15:42.530+0530 E - [main] exiting with code 1
Just figured out the issue.
With mongodb_net_bindip=127.0.0.1 mongodb can be connected from same host only. To enable connecting from remote(any) host set mongodb_net_bindip=0.0.0.0.
hi, i have set mongodb_net_bindip=0.0.0.0, still it says
"module_stdout": "Traceback (most recent call last):\r\n File "/tmp/ansible_fUwl0K/ansible_module_mongodb_replication.py", line 466, in
can you please help with this issue