Closed dirkaholic closed 4 years ago
Probably quite an unusual requirement but this could be easy enough to fix. How about another module parameter, i.e. mongos_process with an obvious default of mongos. i.e.
- name: Add all shards to the cluster
mongodb_shard:
login_host: "{{ item.0.mongos_login_host }}"
login_port: "{{ item.0.mongos_login_port|int }}"
shard: "{{ item.0.replicaset }}/{{ item.1 }}"
state: present
mongos_process: "my-custom-mongos"
loop: "{{ mongodb_shards|subelements('members') }}"
when: item.0.type == 'shard'
run_once: yes
Would this work for you?
I think that would work, yes.
Wow, @rhysmeister that one was fast. Thanks a lot.
Merged to master.
SUMMARY
When adding a shard the module checks for the connected server being a mongos by comparing the process name returned from the serverStatus to 'mongos'. That process name can be changed by using a custom name for the mongos binary (different versions on the same server or other reasons). Therefor the module fails in that case complaining that the process running on the specified host/port is not a mongos.
See https://github.com/ansible-collections/community.mongodb/blob/master/plugins/modules/mongodb_shard.py#L478
ISSUE TYPE
COMPONENT NAME
mongodb_shard
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Debian 10.2
STEPS TO REPRODUCE
Rename the mongos binary to some random name or create a symlink with another name (like custom-mongos-1) and use that for starting the mongos service. The server status of the mongos should show the custom binary in the process field:
Now try adding a shard using the mongodb_shard module.
EXPECTED RESULTS
Shard is added to MongoDB cluster
ACTUAL RESULTS
Migrated issue from https://github.com/ansible/ansible/issues/69256.