Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection_option: "retrywrites=false" appears to be ignored (1.7.6) #677

Closed
randoneering opened this issue Sep 30, 2024 · 5 comments
Closed

Comments

@randoneering
Copy link

randoneering commented Sep 30, 2024

SUMMARY

When passing the connection_option "retryWrites=false" when using the community.mongodb_shell module, it seems the connection option is ignored. The target database instance is an AWS DocumentDB instance, so it is not an officially supported mongodb instance. However, I am able to run the same insert when manually connecting to the instance using mongosh and passing the connection option of "retryWrites=false."

ISSUE TYPE
  • Bug Report
COMPONENT NAME

community.mongodb.mongodb_shell

ANSIBLE VERSION
Ansible version is 2.15.0
COLLECTION VERSION
community.mongodb version is 1.7.6

CONFIGURATION
CONFIG_FILE() = /etc/ansible/ansible.cfg
HOST_KEY_CHEKCING(/etc/ansible/ansible.cfg) = False

OS / ENVIRONMENT

RHEL 8

STEPS TO REPRODUCE
---
- name: Initialization of MongoDB Instance
  hosts: all
  tasks:
    - name: Create database
      community.mongodb.mongodb_shell:
          login_host: "{{ mongodb_host }}"
          login_database: foo
          login_user: "{{ db_username }}"
          login_password: "{{ db_password }}"
          login_port: 27017
          eval: 'db.scriptResults.insertOne({ "name": dba_init", "status": "ran", "execution": new Date() })'
          ssl: true
         ssl_ca_certs: "pathtocert"
         connection_options:
             - "retryWrites=false"
EXPECTED RESULTS

The insert is successful

ACTUAL RESULTS
{
   "msg": "MongoServerError: Retryable writes are not supported",
   "invocation": {
      "module_args": {
         "login_host": "foobar.rds.instance",
         "login_database": "foo",
         "login_user": "redacted",
         "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
         "login_port": 27017,
         "eval": "EJSON.stringify(db.scriptResults.insertOne({ \"name\": \"dba_init\", \"status\": \"ran\", \"execution\": new Date() }))",
         "ssl": true,
         "ssl_ca_certs": "redacted",
         "connection_options": [
            "retrywrites=false"
         ],
         "strict_compatibility": true,
         "atlas_auth": false,
         "ssl_cert_reqs": "CERT_REQUIRED",
         "mongo_cmd": "mongosh",
         "db": "test",
         "nodb": false,
         "norc": false,
         "quiet": true,
         "debug": false,
         "transform": "auto",
         "split_char": " ",
         "idempotent": false,
         "omit": [],
         "ssl_crlfile": null,
         "ssl_certfile": null,
         "ssl_keyfile": null,
         "ssl_pem_passphrase": null,
         "auth_mechanism": null,
         "file": null,
         "stringify": true,
         "additional_args": null
      }
   },
   "_ansible_no_log": null,
   "changed": false
}
@randoneering
Copy link
Author

I used a playbook of mine to gather system info for this ticket, including ansible version and the community.mongodb collection version. I did not run the requested commands to provide that data, but I am happy to provide the playbook I wrote to do that for me since I do not have terminal access to the box Ansible Tower is hosted on.

@rhysmeister
Copy link
Collaborator

rhysmeister commented Oct 2, 2024

Hi @randoneering,

Hmmm, that should work. What's the version of the pymongo driver? That won't be relevant since this is not a pymongo module. I've reviewed the code here. We don't deal with the connection_options param in the mongodb_shell code. I'll get that looked into.

Rhys

@randoneering
Copy link
Author

Okay-good. I am not crazy. Let me know if you need to test anything!

@rhysmeister
Copy link
Collaborator

@rhysmeister
Copy link
Collaborator

Merged and released. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants