ansible / ansible.builtin / v2.9.17 / module / mongodb_replicaset Initialises a MongoDB replicaset. | "added in version" 2.8 of ansible.builtin" Authors: Rhys Campbell (@rhysmeister) preview | supported by communityansible.builtin.mongodb_replicaset (v2.9.17) — module
pip
Install with pip install ansible==2.9.17
Initialises a MongoDB replicaset in a new deployment.
Validates the replicaset name for existing deployments.
# Create a replicaset called 'rs0' with the 3 provided members - name: Ensure replicaset rs0 exists mongodb_replicaset: login_host: localhost login_user: admin login_password: admin replica_set: rs0 members: - mongodb1:27017 - mongodb2:27017 - mongodb3:27017 when: groups.mongod.index(inventory_hostname) == 0
# Create two single-node replicasets on the localhost for testing - name: Ensure replicaset rs0 exists mongodb_replicaset: login_host: localhost login_port: 3001 login_user: admin login_password: secret login_database: admin replica_set: rs0 members: localhost:3001 validate: no
- name: Ensure replicaset rs1 exists mongodb_replicaset: login_host: localhost login_port: 3002 login_user: admin login_password: secret login_database: admin replica_set: rs1 members: localhost:3002 validate: no
ssl: default: false description: - Whether to use an SSL connection when connecting to the database type: bool members: description: - A comma-separated string or a yaml list consisting of the replicaset members. - Supply as a simple csv string, i.e. mongodb1:27017,mongodb2:27017,mongodb3:27017. - If a port number is not provided then 27017 is assumed. type: list validate: default: true description: - Performs some basic validation on the provided replicaset config. type: bool login_host: default: localhost description: - The MongoDB hostname. type: str login_port: default: 27017 description: - The MongoDB port to login to. type: int login_user: description: - The username to authenticate with. type: str replica_set: default: rs0 description: - Replicaset name. type: str ssl_cert_reqs: 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. type: str login_database: default: admin description: - The database where login credentials are stored. type: str login_password: description: - The password to authenticate with. type: str arbiter_at_index: description: - Identifies the position of the member in the array that is an arbiter. type: int chaining_allowed: default: true description: - When I(settings.chaining_allowed=true), the replicaset allows secondary members to replicate from other secondary members. - When I(settings.chaining_allowed=false), secondaries can replicate only from the primary. type: bool protocol_version: choices: - 0 - 1 default: 1 description: Version of the replicaset election protocol. type: int heartbeat_timeout_secs: default: 10 description: - Number of seconds that the replicaset members wait for a successful heartbeat from each other. - If a member does not respond in time, other members mark the delinquent member as inaccessible. - The setting only applies when using I(protocol_version=0). When using I(protocol_version=1) the relevant setting is I(settings.election_timeout_millis). type: int election_timeout_millis: default: 10000 description: - The time limit in milliseconds for detecting when a replicaset's primary is unreachable. type: int
mongodb_replicaset: description: The name of the replicaset that has been created. returned: success type: str