community / community.mongodb / 1.6.1 / module / mongodb_shard Add or remove shards from a MongoDB Cluster | "added in version" 1.0.0 of community.mongodb" Authors: Rhys Campbell (@rhysmeister)community.mongodb.mongodb_shard (1.6.1) — module
Install with ansible-galaxy collection install community.mongodb:==1.6.1
collections: - name: community.mongodb version: 1.6.1
Add or remove shards from a MongoDB Cluster.
- name: Add a replicaset shard named rs1 with a member running on port 27018 on mongodb0.example.net community.mongodb.mongodb_shard: login_user: admin login_password: admin shard: "rs1/mongodb0.example.net:27018" state: present
- name: Add a standalone mongod shard running on port 27018 of mongodb0.example.net community.mongodb.mongodb_shard: login_user: admin login_password: admin shard: "mongodb0.example.net:27018" state: present
- name: To remove a shard called 'rs1' community.mongodb.mongodb_shard: login_user: admin login_password: admin shard: rs1 state: absent
# Single node shard running on localhost - name: Ensure shard rs0 exists community.mongodb.mongodb_shard: login_user: admin login_password: secret shard: "rs0/localhost:3001" state: present
# Single node shard running on localhost - name: Ensure shard rs1 exists community.mongodb.mongodb_shard: login_user: admin login_password: secret shard: "rs1/localhost:3002" state: present
# Enable sharding on a few databases when creating the shard - name: To remove a shard called 'rs1' community.mongodb.mongodb_shard: login_user: admin login_password: admin shard: rs1 sharded_databases: - db1 - db2 state: present
ssl: aliases: - tls default: false description: - Whether to use an SSL connection when connecting to the database. required: false type: bool shard: description: - The shard connection string. - Should be supplied in the form <replicaset>/host:port as detailed in U(https://docs.mongodb.com/manual/tutorial/add-shards-to-shard-cluster/). - For example rs0/example1.mongodb.com:27017. required: true type: str state: choices: - absent - present default: present description: - Whether the shard should be present or absent from the Cluster. required: false type: str atlas_auth: default: false description: - Authentication path intended for MongoDB Atlas Instances type: bool login_host: default: localhost description: - The host running MongoDB instance to login to. required: false type: str login_port: default: 27017 description: - The MongoDB server port to login to. required: false type: int login_user: description: - The MongoDB user to login with. - Required when I(login_password) is specified. required: false type: str ssl_crlfile: description: - The ssl_crlfile option takes a path to a CRL file. required: false type: str ssl_keyfile: description: - Private key for the client certificate. required: false type: str ssl_ca_certs: aliases: - tlsCAFile description: - The ssl_ca_certs option takes a path to a CA file. required: false type: str ssl_certfile: aliases: - tlsCertificateKeyFile description: - Present a client certificate using the ssl_certfile option. required: false type: str ssl_cert_reqs: aliases: - tlsAllowInvalidCertificates choices: - CERT_NONE - CERT_OPTIONAL - CERT_REQUIRED default: CERT_REQUIRED description: - Specifies whether a certificate is required from the other side of the connection, and whether it will be validated if provided. required: false type: str auth_mechanism: choices: - SCRAM-SHA-256 - SCRAM-SHA-1 - MONGODB-X509 - GSSAPI - PLAIN description: - Authentication type. required: false type: str login_database: default: admin description: - The database where login credentials are stored. required: false type: str login_password: description: - The password used to authenticate with. - Required when I(login_user) is specified. required: false type: str mongos_process: default: mongos description: - Provide a custom name for the mongos process you are connecting to. - Most users can ignore this setting. required: false type: str sharded_databases: description: - Enable sharding on the listed database. - Can be supplied as a string or a list of strings. - Sharding cannot be disabled on a database. - Starting in MongoDB 6.0, the enableSharding command is no longer required to shard a collection and this parameter is ignored. required: false type: raw connection_options: description: - Additional connection options. - Supply as a list of dicts or strings containing key value pairs seperated with '='. elements: raw required: false type: list ssl_pem_passphrase: aliases: - tlsCertificateKeyFilePassword description: - Passphrase to decrypt encrypted private keys. required: false type: str strict_compatibility: default: true description: - Enforce strict requirements for pymongo and MongoDB software versions type: bool
mongodb_shard: description: The name of the shard to create. returned: success type: str sharded_enabled: description: Databases that have had sharding enabled during module execution. returned: success when sharding is enabled type: list