cloudera.services.ranger_policy module – Manage policies in Apache Ranger
Note
This module is part of the cloudera.services collection (version 1.0.0).
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 git+https://github.com/cloudera-labs/cloudera.services.git.
To use it in a playbook, specify: cloudera.services.ranger_policy.
New in cloudera.services 1.1.0
Synopsis
Create, update, or delete policies in Apache Ranger.
Parameters
Parameter |
Comments |
|---|---|
Additional resource definitions. |
|
List of allow exception policy items. |
|
List of access types and whether each is allowed. |
|
Whether this access type is allowed. Choices:
|
|
The access type (e.g. |
|
List of custom conditions for the policy item. |
|
The type of the condition. |
|
The values associated with the condition. |
|
Whether users/groups of this policy item are allowed to update the policy. Choices:
|
|
List of groups the policy item applies to. |
|
List of roles the policy item applies to. |
|
List of users the policy item applies to. |
|
The path to a client certificate for authenticating to the API endpoint. |
|
The path to a client key for authenticating to the API endpoint. |
|
List of custom conditions for the policy. |
|
The type of the condition. |
|
The values associated with the condition. |
|
List of data masking policy items. |
|
List of access types and whether each is allowed. |
|
Whether this access type is allowed. Choices:
|
|
The access type (e.g. |
|
List of custom conditions for the policy item. |
|
The type of the condition. |
|
The values associated with the condition. |
|
The data masking configuration to apply. |
|
The condition expression controlling when the mask applies. |
|
The type of data masking to apply. |
|
The expression used to compute the masked value. |
|
Whether users/groups of this policy item are allowed to update the policy. Choices:
|
|
List of groups the policy item applies to. |
|
List of roles the policy item applies to. |
|
List of users the policy item applies to. |
|
A flag to enable debug logging of the module’s execution. Choices:
|
|
List of deny exception policy items. |
|
List of access types and whether each is allowed. |
|
Whether this access type is allowed. Choices:
|
|
The access type (e.g. |
|
List of custom conditions for the policy item. |
|
The type of the condition. |
|
The values associated with the condition. |
|
Whether users/groups of this policy item are allowed to update the policy. Choices:
|
|
List of groups the policy item applies to. |
|
List of roles the policy item applies to. |
|
List of users the policy item applies to. |
|
List of deny policy items. |
|
List of access types and whether each is allowed. |
|
Whether this access type is allowed. Choices:
|
|
The access type (e.g. |
|
List of custom conditions for the policy item. |
|
The type of the condition. |
|
The values associated with the condition. |
|
Whether users/groups of this policy item are allowed to update the policy. Choices:
|
|
List of groups the policy item applies to. |
|
List of roles the policy item applies to. |
|
List of users the policy item applies to. |
|
Description of the policy. |
|
A flag to force a refresh of the API request, ignoring any cached results. Choices:
|
|
A flag to force basic authentication for API requests. Choices:
|
|
The User-Agent string to send with API requests. Default: |
|
Whether auditing is enabled for the policy. Choices:
|
|
Whether to deny all other accesses not explicitly allowed by the policy. Choices:
|
|
Whether the policy is enabled. Choices:
|
|
Whether to merge the provided policy items with the existing policy or replace it entirely. When When Choices:
|
|
Name of the policy. |
|
Dictionary of additional options for the policy. |
|
The number of items to return per page in a paginated API response. Default: |
|
List of allow policy items. |
|
List of access types and whether each is allowed. |
|
Whether this access type is allowed. Choices:
|
|
The access type (e.g. |
|
List of custom conditions for the policy item. |
|
The type of the condition. |
|
The values associated with the condition. |
|
Whether users/groups of this policy item are allowed to update the policy. Choices:
|
|
List of groups the policy item applies to. |
|
List of roles the policy item applies to. |
|
List of users the policy item applies to. |
|
List of labels associated with the policy. |
|
Priority of the policy. |
|
Type of the policy. |
|
Dictionary of resource definitions for the policy. |
|
List of row filtering policy items. |
|
List of access types and whether each is allowed. |
|
Whether this access type is allowed. Choices:
|
|
The access type (e.g. |
|
List of custom conditions for the policy item. |
|
The type of the condition. |
|
The values associated with the condition. |
|
Whether users/groups of this policy item are allowed to update the policy. Choices:
|
|
List of groups the policy item applies to. |
|
List of roles the policy item applies to. |
|
The row filter configuration to apply. |
|
The filter expression applied to rows. |
|
List of users the policy item applies to. |
|
Name of the Ranger service associated with the policy. |
|
Type of the service (e.g., hive, hdfs) this policy applies to. |
|
Whether the policy should be present or absent. Choices:
|
|
The timeout in seconds for any API requests. Default: |
|
The base URL of the API endpoint, including the port if necessary. |
|
The password for authenticating to the API endpoint. |
|
The username for authenticating to the API endpoint. |
|
A flag to enable or disable GSSAPI authentication for API requests. Choices:
|
|
A flag to enable or disable the use of a proxy for API requests. Choices:
|
|
A flag to enable or disable SSL certificate validation for API requests. Choices:
|
|
Time-based policy schedules. |
|
The end time of the validity schedule. |
|
List of recurrence definitions for the schedule. |
|
The recurrence interval definition. |
|
The recurrence schedule definition. |
|
The start time of the validity schedule. |
|
The time zone the schedule times are expressed in. |
|
Name of the security zone the policy belongs to. |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
This module supports check mode. |
|
Support: full |
This module supports diff mode. |
Notes
Note
When
merged=false(default), the module performs full replacements of existing policies rather than merges.If the desired state differs from the current policy, the existing policy is fully overwritten with the new definition.
This guarantees consistent, predictable updates and avoids the risk of duplicate or conflicting entries.
When
merged=true, the module concatenates lists (users, groups, accesses) with the existing ones.Merge mode is useful for adding users, groups, or accesses to existing policies without specifying all current values.
Values already present are not duplicated when merging.
Examples
# NOTE: Examples do not include connection and authentication fields
- name: Create a basic Ranger policy
cloudera.services.ranger_policy:
name: "Test Policy 2"
service: "cm_hdfs"
service_type: "hdfs"
description: "Description1"
resources:
path:
values:
- "/hbase/archive2"
- name: Update an existing Ranger policy
cloudera.services.ranger_policy:
name: "Policy test create request"
service: "cm_hdfs"
resources:
path:
values:
- "/tmp/test"
- name: Create a policy with users, groups, and multiple accesses
cloudera.services.ranger_policy:
name: "atlas-policy"
service: "cm_atlas"
resources:
entity-type:
values:
- "hive_table"
access_policies:
- accesses:
- type: "type-create"
is_allowed: true
- type: "type-read"
is_allowed: true
users:
- "admin"
- "impala"
- "flink"
- "zookeeper"
groups:
- "public"
roles: []
conditions: []
- name: Add a user to an existing policy using merge mode
cloudera.services.ranger_policy:
name: "all - database, table"
service: "cm_kudu"
merged: true
access_policies:
- users:
- "kafka"
accesses:
- type: "select"
is_allowed: true
- name: Delete a Ranger policy
cloudera.services.ranger_policy:
name: "Test Policy 6"
service: "cm_hdfs"
state: "absent"
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
A dictionary containing details about the policy. Returned: always |
|
List of additional resource definitions. Returned: always |
|
Whether the specified values are excluded rather than included. Returned: always |
|
Whether the resource match is applied recursively. Returned: always |
|
List of resource values matched by this resource definition. Returned: always |
|
List of allow exception policy items. Returned: always |
|
List of access types and whether each is allowed. Returned: always |
|
Whether this access type is allowed. Returned: always |
|
The access type (e.g. Returned: always |
|
List of custom conditions for the policy item. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
Whether users/groups of this policy item are allowed to update the policy. Returned: always |
|
List of groups the policy item applies to. Returned: always |
|
List of roles the policy item applies to. Returned: always |
|
List of users the policy item applies to. Returned: always |
|
List of policy conditions. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
Epoch timestamp when the policy was created. Returned: always |
|
Username of the policy creator. Returned: always |
|
List of data mask policy items. Returned: always |
|
List of access types and whether each is allowed. Returned: always |
|
Whether this access type is allowed. Returned: always |
|
The access type (e.g. Returned: always |
|
List of custom conditions for the policy item. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
The data masking configuration applied by this policy item. Returned: always |
|
The condition expression controlling when the mask applies. Returned: always |
|
The type of data masking to apply. Returned: always |
|
The expression used to compute the masked value. Returned: always |
|
Whether users/groups of this policy item are allowed to update the policy. Returned: always |
|
List of groups the policy item applies to. Returned: always |
|
List of roles the policy item applies to. Returned: always |
|
List of users the policy item applies to. Returned: always |
|
List of deny exception policy items. Returned: always |
|
List of access types and whether each is allowed. Returned: always |
|
Whether this access type is allowed. Returned: always |
|
The access type (e.g. Returned: always |
|
List of custom conditions for the policy item. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
Whether users/groups of this policy item are allowed to update the policy. Returned: always |
|
List of groups the policy item applies to. Returned: always |
|
List of roles the policy item applies to. Returned: always |
|
List of users the policy item applies to. Returned: always |
|
List of deny policy items. Returned: always |
|
List of access types and whether each is allowed. Returned: always |
|
Whether this access type is allowed. Returned: always |
|
The access type (e.g. Returned: always |
|
List of custom conditions for the policy item. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
Whether users/groups of this policy item are allowed to update the policy. Returned: always |
|
List of groups the policy item applies to. Returned: always |
|
List of roles the policy item applies to. Returned: always |
|
List of users the policy item applies to. Returned: always |
|
Optional description of the policy. Returned: always |
|
Globally unique identifier for the policy. Returned: always |
|
Unique numeric ID of the policy. Returned: always |
|
Whether auditing is enabled for the policy. Returned: always |
|
Whether the policy denies all accesses not explicitly allowed. Returned: always |
|
Whether the policy is currently enabled. Returned: always |
|
Name of the policy. Returned: always |
|
Dictionary of additional policy options. Returned: always |
|
List of allow policy items. Returned: always |
|
List of access types and whether each is allowed. Returned: always |
|
Whether this access type is allowed. Returned: always |
|
The access type (e.g. Returned: always |
|
List of custom conditions for the policy item. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
Whether users/groups of this policy item are allowed to update the policy. Returned: always |
|
List of groups the policy item applies to. Returned: always |
|
List of roles the policy item applies to. Returned: always |
|
List of users the policy item applies to. Returned: always |
|
List of policy labels. Returned: always |
|
Priority value for the policy. Returned: always |
|
Numeric identifier for the type of policy. Returned: always |
|
Signature hash of the resources in the policy. Returned: always |
|
Dictionary of resources the policy applies to. Returned: always |
|
Whether the specified values are excluded rather than included. Returned: always |
|
Whether the resource match is applied recursively. Returned: always |
|
List of resource values matched by this resource definition. Returned: always |
|
List of row filter policy items. Returned: always |
|
List of access types and whether each is allowed. Returned: always |
|
Whether this access type is allowed. Returned: always |
|
The access type (e.g. Returned: always |
|
List of custom conditions for the policy item. Returned: always |
|
The type of the condition. Returned: always |
|
The values associated with the condition. Returned: always |
|
Whether users/groups of this policy item are allowed to update the policy. Returned: always |
|
List of groups the policy item applies to. Returned: always |
|
List of roles the policy item applies to. Returned: always |
|
The row filter configuration applied by this policy item. Returned: always |
|
The filter expression applied to rows. Returned: always |
|
List of users the policy item applies to. Returned: always |
|
Name of the service this policy applies to. Returned: always |
|
Type of the service (e.g., hive, hdfs) this policy applies to. Returned: always |
|
Epoch timestamp when the policy was last updated. Returned: always |
|
Username of the last person who updated the policy. Returned: always |
|
List of validity schedules attached to the policy. Returned: always |
|
The end time of the validity schedule. Returned: always |
|
List of recurrence definitions for the schedule. Returned: always |
|
The recurrence interval definition. Returned: always |
|
The recurrence schedule definition. Returned: always |
|
The start time of the validity schedule. Returned: always |
|
The time zone the schedule times are expressed in. Returned: always |
|
Version number of the policy. Returned: always |
|
Name of the security zone this policy belongs to. Returned: always |