{"id":14956829,"url":"https://github.com/trfore/ansible-role-mongodb-install","last_synced_at":"2025-10-24T10:31:03.442Z","repository":{"id":154405360,"uuid":"632087979","full_name":"trfore/ansible-role-mongodb-install","owner":"trfore","description":"Ansible role for installing MongoDB Community Edition on RedHat/CentOS and Debian/Ubuntu","archived":false,"fork":false,"pushed_at":"2024-10-26T02:23:07.000Z","size":119,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T14:21:16.614Z","etag":null,"topics":["ansible-role","homelab","mongo-db","mongodb-database"],"latest_commit_sha":null,"homepage":"https://galaxy.ansible.com/ui/standalone/roles/trfore/mongodb_install/","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trfore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-24T17:24:48.000Z","updated_at":"2024-07-16T02:52:06.000Z","dependencies_parsed_at":"2024-01-20T03:25:24.637Z","dependency_job_id":"a4a40681-0dc7-4ce1-a264-2c50e6b5b669","html_url":"https://github.com/trfore/ansible-role-mongodb-install","commit_stats":{"total_commits":109,"total_committers":2,"mean_commits":54.5,"dds":0.06422018348623848,"last_synced_commit":"1ffae9fa2feefd4e70cca334c72af7bcbfbc00e9"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fansible-role-mongodb-install","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fansible-role-mongodb-install/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fansible-role-mongodb-install/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trfore%2Fansible-role-mongodb-install/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trfore","download_url":"https://codeload.github.com/trfore/ansible-role-mongodb-install/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237950886,"owners_count":19392667,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible-role","homelab","mongo-db","mongodb-database"],"created_at":"2024-09-24T13:13:35.931Z","updated_at":"2025-10-24T10:31:03.430Z","avatar_url":"https://github.com/trfore.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible Role: mongodb_install\n\n[![CI](https://github.com/trfore/ansible-role-mongodb-install/actions/workflows/ci.yml/badge.svg)](https://github.com/trfore/ansible-role-mongodb-install/actions/workflows/ci.yml)\n[![Prerelease](https://github.com/trfore/ansible-role-mongodb-install/actions/workflows/prerelease.yml/badge.svg)](https://github.com/trfore/ansible-role-mongodb-install/actions/workflows/prerelease.yml)\n[![Galaxy Release](https://github.com/trfore/ansible-role-mongodb-install/actions/workflows/release.yml/badge.svg)](https://github.com/trfore/ansible-role-mongodb-install/actions/workflows/release.yml)\n\nThis role installs the MongoDB Community edition server metapackage, `mongodb-org`, via the OS's package manager. It currently defaults to installing the **latest release from version 7**, you can install a newer major version by setting `mongodb_version: 8.0.15`, see 'Tested Platforms and Versions' section for a compatibility matrix.\n\nSee [Example Playbooks](#example-playbooks) for working examples. **The default settings do not configure the server**, it uses the default configuration values and minimal recommended `ulimit` settings. Its recommended to configure the server for production use, for details see: https://www.mongodb.com/docs/manual/administration/production-notes/\n\n### Install the Role\n\nYou can install this role with the Ansible Galaxy CLI:\n\n```bash\nansible-galaxy install trfore.mongodb_install\n```\n\nYou can also include it in a `requirements.yml` file and install it with `ansible-galaxy install -r requirements.yml`, using the format:\n\n```yaml\n---\nroles:\n  - name: trfore.mongodb_install\n    version: v3.0.4 # optional\n\ncollections:\n  # required when targeting CentOS \u0026 RHEL host\n  - name: community.general\n    source: https://galaxy.ansible.com\n\n  # required if using Transparent HugePages, e.g. 'mongodb_security_authorization: enable'\n  - name: community.mongodb\n    source: https://galaxy.ansible.com\n```\n\n## Tested Platforms and Versions\n\n### MongoDB Community `8.0.15`\n\n- CentOS Stream 9\n- Debian 12\n- Ubuntu 22.04 \u0026 24.04\n\n### MongoDB Community `7.0.25`\n\n- CentOS Stream 9\n- Debian 11 \u0026 12\n- Ubuntu 22.04\n\n### MongoDB Community `6.0.25` (EOL July 2025)\n\n- CentOS Stream 9\n- Debian 11\n- Ubuntu 22.04\n\n### MongoDB Community `5.0.31` (EOL October 2024)\n\n- CentOS Stream 8\n- Debian 10 \u0026 11\n- Ubuntu 20.04\n\n### MongoDB Community `4.4.29` (EOL February 2024)\n\n- CentOS Stream 8\n- Debian 10\n- Ubuntu 20.04\n\n## Requirements\n\n- `ansible-core\u003e=2.17.0`\n\n## Dependencies\n\n- `community.general.yum_versionlock` required when targeting CentOS \u0026 RHEL host.\n- `community.mongodb` required when `mongodb_security_authorization: enable`, [see detail below](#user-creation-variables).\n\n  ```bash\n  ansible-galaxy collection install community.general community.mongodb\n  ```\n\n## Role Variables\n\n### Common Variables\n\nCommon variables are listed below, along with default values (see `defaults/main.yml`):\n\n| Variable                                   | Default    | Description                                                                                               | Required  |\n| ------------------------------------------ | ---------- | --------------------------------------------------------------------------------------------------------- | --------- |\n| mongodb_version                            | `7.0.25`   | MongoDB Community stable releases `v4.4`, `v5`, `v6`, `v7`, `v8`                                          | No        |\n| mongodb_version_maj                        | Automatic  | Extracts major value from `mongodb_version`                                                               | Automatic |\n| mongodb_version_maj_minor                  | Automatic  | Extracts major and minor values from `mongodb_version`                                                    | Automatic |\n| mongodb_transparent_hugepages_optimization | `false`    | Disable Transparent HugePages (THP) for MongoDB ≤ 7 or enable Transparent HugePages (THP) for MongoDB ≥ 8 | No        |\n| mongodb_security_authorization             | `disabled` | MongoDB `authorization` setting in `mongod.conf`, e.g. `enabled` or `disabled`                            | No        |\n| hostname                                   | ``         | Set the hostname for the MongoDB server (useful for some monitoring tools).                               | No        |\n\n### Package Install Variables\n\n`defaults/main.yml`:\n\n| Variable              | Default          | Description                                                           | Required |\n| --------------------- | ---------------- | --------------------------------------------------------------------- | -------- |\n| mongodb_gpg_key       | URL              | MongoDB GPG Key                                                       | No       |\n| mongodb_pkg_hold      | `true`           | Boolean, `true` to hold package version                               | No       |\n| mongodb_pkg_hold_list | MongoDB Packages | List of MongoDB packages installed from `mongodb-org`, `v4.4` to `v7` | No       |\n\n### User Creation Variables\n\nSet these to automatically create users during provisioning. If `mongodb_security_authorization` is set to `enabled`, the users will be created after mongod starts (see `defaults/main.yml`).\n\n| Variable                     | Default      | Description                                                     | Required |\n| ---------------------------- | ------------ | --------------------------------------------------------------- | -------- |\n| disable_logging_for_auth     | `false`      | Boolean, suppress auth info in Ansible output (e.g., passwords) | No       |\n| mongodb_user_admin_name      | `UserAdmin`  | Administrative user name                                        | No       |\n| mongodb_user_admin_password  | `passw01d`   | Administrative user password                                    | No       |\n| mongodb_root_admin_name      | `RootAdmin`  | Root user name                                                  | No       |\n| mongodb_root_admin_password  | `passw01d`   | Root user password                                              | No       |\n| mongodb_root_backup_name     | `BackupUser` | Backup user name                                                | No       |\n| mongodb_root_backup_password | `passw01d`   | Backup user password                                            | No       |\n\n### Systemd Resource Limits\n\n`defaults/main.yml`:\n\n| Variable                          | Default | Description           | Required |\n| --------------------------------- | ------- | --------------------- | -------- |\n| mongodb_systemd_unit_limit_nofile | `64000` | File descriptor limit | No       |\n| mongodb_systemd_unit_limit_nproc  | `64000` | Process count limit   | No       |\n\n### Other OS Specific Variables\n\n`vars/debian.yml`:\n\n| Variable              | Default                             | Description                                           | Required |\n| --------------------- | ----------------------------------- | ----------------------------------------------------- | -------- |\n| mongodb_path_db       | `/var/lib/mongodb`                  | PATH, MongoDB database folder                         | No       |\n| mongodb_path_log      | `/var/log/mongodb`                  | PATH, MongoDB log folder                              | No       |\n| mongodb_dependencies  | `[\"libcurl4\",\"openssl\",\"liblzma5\"]` | Required packages for MongoDB                         | No       |\n| mongodb_pkg_hold_list | MongoDB Packages                    | List of MongoDB packages installed from `mongodb-org` | No       |\n\n`vars/redhat.yml` and `vars/redhat_mongo_v{4-8}.yml`:\n\n| Variable              | Default                 | Description                                           | Required |\n| --------------------- | ----------------------- | ----------------------------------------------------- | -------- |\n| mongodb_path_db       | `/var/lib/mongo`        | PATH, MongoDB database folder                         | No       |\n| mongodb_path_log      | `/var/log/mongodb`      | PATH, MongoDB log folder                              | No       |\n| mongodb_dependencies  | `[\"openssl\",\"xz-libs\"]` | Required packages for MongoDB                         | No       |\n| mongodb_pkg_hold_list | MongoDB Packages        | List of MongoDB packages installed from `mongodb-org` | No       |\n\n## Example Playbooks\n\n- Package install via distribution's package manager.\n\n```yaml\n- hosts: servers\n  become: true\n  roles:\n    - name: Install MongoDB\n      role: trfore.mongodb_install\n```\n\n```yaml\n- hosts: servers\n  become: true\n  vars:\n    mongodb_version: \"8.0.15\"\n  roles:\n    - name: Install MongoDB\n      role: trfore.mongodb_install\n```\n\n- With authorization, user creation, and THP settings\n\n```yaml\n- hosts: servers\n  become: true\n  vars:\n    hostname: \"mongodb-test\"\n    mongodb_version: \"8.0.15\"\n    mongodb_net_bindip: \"127.0.0.1\"\n    mongodb_net_port: \"27017\"\n\n    mongodb_user_admin_name: main-admin\n    mongodb_user_admin_password: \"mainpassw01d\"\n\n    mongodb_root_admin_name: root-admin\n    mongodb_root_admin_password: \"rootpassw01d\"\n\n    mongodb_root_backup_name: backup-user\n    mongodb_root_backup_password: \"backuppassw01d\"\n\n    mongodb_security_authorization: \"enabled\"\n    disable_logging_for_auth: true\n\n    mongodb_systemd_unit_limit_nofile: 64000\n    mongodb_systemd_unit_limit_nproc: 64000\n\n    # In MongoDB 8.0 and later, ensure that THP is enabled before mongod starts by creating a service file for your platform's initialization system. If you are using MongoDB 7.0 or earlier, disable THP.\n    mongodb_transparent_hugepages_optimization: true\n\n    # Example of how to add a custom configuration to the mongod.conf file (experimental)\n    mongodb_config:\n      processManagement:\n        fork: false\n      systemLog:\n        verbosity: 0\n  roles:\n    - name: Install MongoDB\n      role: trfore.mongodb_install\n```\n\n## License\n\nThis Ansible role is MIT.\n\nMongoDB Community is Server Side Public License software from MongoDB, Inc. For additional information see: https://www.mongodb.com/licensing/server-side-public-license\n\n## Contributors\n\n- [trfore](https://github.com/trfore) - original author and maintainer\n\nSpecial thanks to all those who have [contributed to the project](https://github.com/trfore/ansible-role-mongodb-install/graphs/contributors)!\nInterested in adding a feature or fixing a bug? Checkout the [contributing guide](CONTRIBUTING.md).\n\n## Related Roles \u0026 Playbooks\n\n| Github                         | Ansible Galaxy           |\n| ------------------------------ | ------------------------ |\n| [ansible-role-jsvc]            | [trfore.jsvc]            |\n| [ansible-role-mongodb-install] | [trfore.mongodb_install] |\n| [ansible-role-omada-install]   | [trfore.omada_install]   |\n\n## References\n\n### MongoDB\n\n- \u003chttps://www.mongodb.com/docs/manual/release-notes/\u003e\n- \u003chttps://www.mongodb.com/download-center/community/releases\u003e\n- \u003chttps://www.mongodb.com/docs/manual/administration/install-on-linux/\u003e\n- \u003chttps://www.mongodb.com/docs/manual/administration/production-notes/\u003e\n- \u003chttps://www.mongodb.com/docs/manual/reference/configuration-options/\u003e\n- \u003chttps://www.mongodb.com/docs/manual/reference/ulimit/\u003e\n- [MongoDB Docs: Disabling Transparent Hugepages (THP) for MongoDB 7 or Earlier]\n- [MongoDB Docs: Enabling Transparent Hugepages (THP) for MongoDB 8]\n\n[ansible-role-jsvc]: https://github.com/trfore/ansible-role-jsvc\n[trfore.jsvc]: https://galaxy.ansible.com/trfore/jsvc\n[ansible-role-mongodb-install]: https://github.com/trfore/ansible-role-mongodb-install\n[trfore.mongodb_install]: https://galaxy.ansible.com/trfore/mongodb_install\n[ansible-role-omada-install]: https://github.com/trfore/ansible-role-omada-install\n[trfore.omada_install]: https://galaxy.ansible.com/trfore/omada_install\n[MongoDB Docs: Enabling Transparent Hugepages (THP) for MongoDB 8]: https://www.mongodb.com/docs/manual/administration/tcmalloc-performance/\n[MongoDB Docs: Disabling Transparent Hugepages (THP) for MongoDB 7 or Earlier]: https://www.mongodb.com/docs/manual/tutorial/disable-transparent-huge-pages/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fansible-role-mongodb-install","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrfore%2Fansible-role-mongodb-install","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrfore%2Fansible-role-mongodb-install/lists"}