This Ansible role is used to provision and manage a mongodb cluster.
This project is designed to operate using clusterverse to manage the base infrastructure. Please see the README.md there for detailed instructions on its usage.
- This role works with MongoDB 3.4 and above, including redeploying from one version to the next. Doing so requires some compromises with the Ansible libraries: Most of
community.mongodb.*(exceptmongodb_shell) are designed for MongoDB 4.2 and above, and do not work with lower versions. Where possible, both the.shelland modern library are available, with awhen:condition to select based on the version of MongoDB being deployed. NOTE: because a redeploy from4.0to4.2will be running on both4.0and4.2clusters, we must use theshelllibrary when configuring clusters of>4.2, not>=4.2. - ansible-core >= 2.17.4 (pypi >= 10.4.0)
- See docs/EXAMPLE/Dockerfile for a full list of dependencies.
Please see the EXAMPLE directory in this repository for some basic configuration. This can be copied in the root directory, and used as a starting point for your own configuration.
- Cluster configuration is stored in
cluster_defs/**/cluster_vars[*].ymlfiles. - Application configuration is stored in
cluster_defs/**/app_vars[*].ymlfiles.
- deploy.yml - Deploys a cluster from scratch, or repairs a cluster, or scales it up (note: not down).
- e.g.
ansible-playbook -e buildenv=dev -e cloud_type=aws -e region=eu-west-1 deploy.yml
- e.g.
- redeploy.yml - Redeploys the cluster, replacing all the nodes entirely.
- e.g.
ansible-playbook -e buildenv=dev -e cloud_type=aws -e region=eu-west-1 redeploy.yml
- e.g.
- destroy.yml - Destroys the cluster,
- e.g.
ansible-playbook -e buildenv=dev -e cloud_type=aws -e region=eu-west-1 destroy.yml
- e.g.
- backup_create.yml - Creates a backup of the cluster in S3,
- e.g.
ansible-playbook -e buildenv=dev -e cloud_type=aws -e region=eu-west-1 backup_create.yml
- e.g.
- backup_create.yml - Restores a backup of the cluster from S3,
- e.g.
ansible-playbook -e buildenv=dev -e cloud_type=aws -e region=eu-west-1 backup_restore.yml
- e.g.
For CI/CD, run within the included Docker container
docker build -t ansibuild .docker run --rm --name ansibuilder_monogodb -e VAULT_PASSWORD_BUILDENV=$VAULT_PASSWORD ansibuild ansible-playbook deploy.yml -e cloud_type=aws -e region=eu-west-1 -e buildenv=dev -vvv
mongo_version: The version of MongoDB to install/redeploy, e.g.8.0.18