oci_group – Create,update and delete OCI user groups and specified user associations

New in version 2.5.

Synopsis

  • Creates OCI group, if not present, without any user associations
  • Creates OCI group, if not present, with any specified user associations
  • Update OCI group, if present, with description
  • Update OCI group, if present, with new user(s) associations
  • Update OCI group, if present, removing all user associations
  • Delete OCI group, if present.

Requirements

The below requirements are needed on the host that executes this module.

Parameters

Parameter Choices/Defaults Comments
api_user
string
The OCID of the user, on whose behalf, OCI APIs are invoked. If not set, then the value of the OCI_USER_OCID environment variable, if any, is used. This option is required if the user is not specified through a configuration file (See config_file_location). To get the user's OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_fingerprint
string
Fingerprint for the key pair being used. If not set, then the value of the OCI_USER_FINGERPRINT environment variable, if any, is used. This option is required if the key fingerprint is not specified through a configuration file (See config_file_location). To get the key pair's fingerprint value please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm.
api_user_key_file
string
Full path and filename of the private key (in PEM format). If not set, then the value of the OCI_USER_KEY_FILE variable, if any, is used. This option is required if the private key is not specified through a configuration file (See config_file_location). If the key is encrypted with a pass-phrase, the api_user_key_pass_phrase option must also be provided.
api_user_key_pass_phrase
string
Passphrase used by the key referenced in api_user_key_file, if it is encrypted. If not set, then the value of the OCI_USER_KEY_PASS_PHRASE variable, if any, is used. This option is required if the key passphrase is not specified through a configuration file (See config_file_location).
auth_type
string
    Choices:
  • api_key ←
  • instance_principal
The type of authentication to use for making API requests. By default auth_type="api_key" based authentication is performed and the API key (see api_user_key_file) in your config file will be used. If this 'auth_type' module option is not specified, the value of the OCI_ANSIBLE_AUTH_TYPE, if any, is used. Use auth_type="instance_principal" to use instance principal based authentication when running ansible playbooks within an OCI compute instance.
config_file_location
string
Path to configuration file. If not set then the value of the OCI_CONFIG_FILE environment variable, if any, is used. Otherwise, defaults to ~/.oci/config.
config_profile_name
string
The profile to load from the config file referenced by config_file_location. If not set, then the value of the OCI_CONFIG_PROFILE environment variable, if any, is used. Otherwise, defaults to the "DEFAULT" profile in config_file_location.
defined_tags
dictionary
Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm.
delete_user_memberships
boolean
    Choices:
  • no ←
  • yes
Delete users in existing memberships which are present in the users memberships provided by users. If delete_user_memberships=yes, users provided by users would be deleted from existing user memberships, if they are part of existing user memberships. If they are not part of existing user memberships, they will be ignored. delete_user_memberships and purge_user_memberships are mutually exclusive.
description
-
Description of the group. The value could be an empty string. Mandatory for state=present. Not required for state=absent
force
-
Default:
"no"
If force='no' and group has any user assigned, then in the case of state=absent, group will not be deleted. To delete a group which has user associations, force='yes' should be specified.
freeform_tags
dictionary
Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. For more information, see https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm.
group_id
-
Identifier of the Group. Mandatory for delete and update.

aliases: id
name
- / required
Name of the group. Must be unique within a tenancy.
purge_user_memberships
boolean
    Choices:
  • no ←
  • yes
Purge users in existing memberships which are not present in the provided users memberships. If purge_user_memberships=no, provided users would be appended to existing user memberships. purge_user_memberships and delete_user_memberships are mutually exclusive.
region
string
The Oracle Cloud Infrastructure region to use for all OCI API requests. If not set, then the value of the OCI_REGION variable, if any, is used. This option is required if the region is not specified through a configuration file (See config_file_location). Please refer to https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/regions.htm for more information on OCI regions.
state
-
    Choices:
  • present ←
  • absent
Create,update or delete group. For state=present, if the group does not exists, it gets created. If exists, it gets updated. For state=absent, group gets deleted.
tenancy
string
OCID of your tenancy. If not set, then the value of the OCI_TENANCY variable, if any, is used. This option is required if the tenancy OCID is not specified through a configuration file (See config_file_location). To get the tenancy OCID, please refer https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/apisigningkey.htm
users
-
List of users to be associated with the group. The specified users must exist while running this task. If a specified user does not exist, this task would fail.
wait
boolean
    Choices:
  • no
  • yes ←
Whether to wait for create or delete operation to complete.
wait_timeout
integer
Default:
1200
Time, in seconds, to wait when wait=yes.
wait_until
string
The lifecycle state to wait for the resource to transition into when wait=yes. By default, when wait=yes, we wait for the resource to get into ACTIVE/ATTACHED/AVAILABLE/PROVISIONED/ RUNNING applicable lifecycle state during create operation & to get into DELETED/DETACHED/ TERMINATED lifecycle state during delete operation.

Examples

# Note: These examples do not set authentication details.

# Group creation
- name: Create group
  oci_group:
            name: 'AnsibleTestGroup'
            description: 'Group for Testing Ansible Module'
            users: ['user1','user2']
            freeform_tags:
                 group_name: 'designer'
            defined_tags:
                product:
                  type: 'server'
            state: 'present'

- name: Update group by purging existing user memberships
  oci_group:
            id: ocid1.group.oc1..xxxxxEXAMPLExxxxx
            description: 'Group for Testing Ansible Module'
            purge_user_memberships: True
            users: ['user1','user3']
            state: 'present'

- name: Update group by deleting existing user memberships
  oci_group:
            id: ocid1.group.oc1..xxxxxEXAMPLExxxxx
            description: 'Group for Testing Ansible Module'
            delete_user_memberships: True
            users: ['user1']
            state: 'present'

- name: Create group without users associations
  oci_group:
            name: 'AnsibleTestGroup'
            description: 'Group for Testing Ansible Module'
            state: 'present'

- name: Delete all User associations of a Group
  oci_group:
            id: ocid1.group.oc1..xxxxxEXAMPLExxxxx
            description: 'Group for Testing Ansible Module'
            users: []
            state: 'present'

# Delete group
- name :  Forcefully delete a group and any user associations it may have
  oci_group:
            id: ocid1.group.oc1..xxxxxEXAMPLExxxxx
            force: 'yes'
            state: 'absent'

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key Returned Description
group
complex
success
Attributes of the created/updated group. For delete, deleted group description will be returned.

Sample:
[{'lifecycle_state': 'ACTIVE', 'inactive_status': None, 'name': 'network_admin_group', 'compartment_id': 'ocidv1:tenancy:oc1:phx:xxxxxEXAMPLExxxxx', 'defined_tags': {'product': {'type': 'server'}}, 'freeform_tags': {'group_name': 'designer'}, 'time_created': '2017-10-31T16:38:22.289000+00:00', 'id': 'ocid1.group.oc1..xxxxxEXAMPLExxxxx', 'description': 'Network Admin Group'}]
  compartment_id
string
always
Identifier of the tenancy containing the group

Sample:
ocid1.xzvf..oifds
  description
string
always
Description of the group

Sample:
Network Admin Group
  id
string
always
Identifier of the group

Sample:
ocid1.group.oc1.axdf
  inactive_status
string
when group's lifecycle_state is INACTIVE
The detailed status of INACTIVE life cycle state

  lifecycle_state
string
always
Current state of the group

Sample:
ACTIVE
  name
string
always
Unique name of the group

Sample:
network_admin
  time_created
datetime
always
Date and time the group was created, in the format defined by RFC3339

Sample:
2016-08-25 21:10:29.600000


Status

  • This module is not guaranteed to have a backwards compatible interface. [preview]
  • This module is maintained by the Ansible Community. [community]

Authors

  • Debayan Gupta(@debayan_gupta)

Hint

If you notice any issues in this documentation you can edit this document to improve it.