community.mongodb.mongodb_atlas_org_invite module – Manage Atlas organization user invitations

Note

This module is part of the community.mongodb collection (version 1.8.0).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.mongodb.

To use it in a playbook, specify: community.mongodb.mongodb_atlas_org_invite.

Synopsis

  • Invite users to a MongoDB Atlas organization with specified org and project roles.

  • If the user already exists in the org, the module reports no change (idempotent).

  • If a pending invite for the user already exists, the module reports no change.

  • Uses OAuth2 client_credentials (Service Account) for authentication.

  • API Documentation

Parameters

Parameter

Comments

api_password

aliases: apiPassword

string

Atlas API private key. Alternative to service_account_secret.

api_username

aliases: apiUsername

string

Atlas API public key. Alternative to service_account_id.

group_role_assignments

list / elements=dictionary

Optional list of project-level role assignments.

Default: []

group_id

aliases: groupId

string / required

Atlas project ID.

roles

list / elements=string / required

List of project-level roles (e.g. GROUP_READ_ONLY, GROUP_DATA_ACCESS_READ_ONLY).

org_id

aliases: orgId

string / required

Unique identifier of the Atlas organization.

roles

list / elements=string / required

List of org-level roles to assign (e.g. ORG_OWNER, ORG_MEMBER, ORG_READ_ONLY).

service_account_id

aliases: serviceAccountId

string

MongoDB Atlas Service Account client ID (OAuth2).

Mutually exclusive with api_username.

service_account_secret

aliases: serviceAccountSecret

string

MongoDB Atlas Service Account client secret (OAuth2).

Mutually exclusive with api_password.

state

string

present ensures the user is invited or already a member.

absent removes a pending invitation (does not remove existing org members).

Choices:

  • "present" ← (default)

  • "absent"

username

string / required

Email address of the user to invite.

Examples

- name: Invite user as org owner
  community.mongodb.mongodb_atlas_org_invite:
    service_account_id: "mdb_sa_id_xxxx"
    service_account_secret: "mdb_sa_sk_xxxx"
    org_id: "694ec9ddbaecce170ffe8b62"
    username: "newuser@d360.com"
    roles:
      - ORG_OWNER

- name: Invite user with org and project roles
  community.mongodb.mongodb_atlas_org_invite:
    service_account_id: "mdb_sa_id_xxxx"
    service_account_secret: "mdb_sa_sk_xxxx"
    org_id: "694ec9ddbaecce170ffe8b62"
    username: "analyst@d360.com"
    roles:
      - ORG_MEMBER
    group_role_assignments:
      - group_id: "6991db0a32bf1b56dbb63d62"
        roles:
          - GROUP_READ_ONLY

- name: Revoke pending invitation
  community.mongodb.mongodb_atlas_org_invite:
    service_account_id: "mdb_sa_id_xxxx"
    service_account_secret: "mdb_sa_sk_xxxx"
    org_id: "694ec9ddbaecce170ffe8b62"
    username: "newuser@d360.com"
    roles: []
    state: absent

Authors

  • Karol Murawski (@kazz3m)