graphiant.naas.graphiant_data_assurance module – Manage Graphiant Data Assurance policies
Note
This module is part of the graphiant.naas collection (version 26.10.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 graphiant.naas.
You need further requirements to be able to use this module,
see Requirements for details.
To use it in a playbook, specify: graphiant.naas.graphiant_data_assurance.
New in graphiant.naas 26.8.0
Synopsis
Create, update, or delete Graphiant Data Assurance policies via the portal API.
Reads a structured YAML config file and applies the desired state to the Graphiant portal.
Policies may also be supplied directly through the
DataAssurancePoliciesandContentFilterPoliciesmodule parameters, used instead of or together with the config file. When both are given, module parameters are overlaid on the config file per policynameand override the config-file values.Both assurance policies (with
flexAlgo) and block-by-URL/app policies (withoutflexAlgo) are entries in theDataAssurancePolicieslist and are sent to the/v1/data/assurance/assurances/globalendpoint.Block-by-category policies are entries in the
ContentFilterPolicieslist and are sent to the/v1/global/content-filtersendpoint. Each blocks one or more domaincategories(by name, resolved to a domain category ID) with an optionalallowedUrlList(“Allowed URL List”) applied as per-category exception wildcards. Both lists are managed by the same module and operations from a single config file.Configure is idempotent: compares the intended config against live portal state and
skips the update when already matched.
Deconfigure is idempotent: policies not found are silently skipped.
Deleting a policy is a two-step flow: the portal requires a policy to be unassigned from all sites before deletion, so the module first updates it to a detached config (no sites, empty apps/rules) and then deletes it.
With
ansible-playbook --check, writes are skipped butchangedreflects whether an apply would modify at least one policy. Use--diffto previewdetails.diff_plan.
Requirements
The below requirements are needed on the host that executes this module.
python >= 3.7
graphiant-sdk >= 26.10.0
Parameters
Parameter |
Comments |
|---|---|
Bearer token for API authentication (for example, from If not passed as a module argument, the collection reads When a bearer token is present (module argument or environment), it takes precedence over If no valid token is available, the module authenticates with |
|
Block-by-category (content-filter) policies supplied directly as module parameters, as an alternative (or supplement) to the Merged with the config file the same way as |
|
Wildcard URLs allowed through despite the category block (applied as per-category exceptions). |
|
Domain category names to block (resolved to domain category IDs). |
|
LAN segment names the policy applies to. Omit to apply to all segments. |
|
Policy name (unique key used to match/override config-file policies). |
|
Explicit site list ID (used when |
|
Name of a site list to scope the policy to (resolved to its portal site list ID). |
|
Apply the policy to all enterprise sites. Mutually exclusive with Choices:
|
|
Path to the Data Assurance YAML config file. Can be an absolute path or relative to the configured config_path. Supported top-level keys are Each Each entry must have at minimum a Configuration files support Jinja2 templating syntax. Optional. Omit it to configure entirely from the |
|
Assurance and block-by-URL/app policies supplied directly as module parameters, as an alternative (or supplement) to the When both are provided, these entries are overlaid on the config file keyed by policy |
|
Applications to assure or block. |
|
Raw integer bucket ID (use instead of |
|
Graphiant built-in application ID (auto-filled from telemetry when omitted). |
|
Enterprise custom application ID (auto-filled from telemetry when omitted). |
|
Whether the app name is a domain (auto-filled from telemetry when omitted). Choices:
|
|
Application name (validated against the profile’s bucket telemetry). |
|
Human-readable assurance profile name (resolved to an integer |
|
Specific back-end servers to scope to (auto-filled from telemetry when omitted). |
|
Server IP address. |
|
Server port. |
|
Server transport protocol (e.g. |
|
Scope to all observed back-end servers. Choices:
|
|
Flex-algo name defining the SLA metric. Omit for block/protection policies. |
|
LAN segment names the policy applies to. Omit to apply to all segments. |
|
Policy name (unique key used to match/override config-file policies). |
|
Explicit site list ID (used when |
|
Name of a site list to scope the policy to (resolved to its portal site list ID). |
|
Apply the policy to all enterprise sites. Mutually exclusive with Choices:
|
|
Enable detailed logging. Choices:
|
|
Graphiant portal host URL for API connectivity. Example: “https://api.graphiant.com” |
|
Specific operation to perform.
Choices:
|
|
Graphiant portal password for authentication. Required for password-based login when no valid bearer token is available from |
|
Desired state for Data Assurance policies.
Choices:
|
|
Graphiant portal username for authentication. Required for password-based login when no valid bearer token is available from |
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full In check mode, no writes are sent to the portal, but the module still reads current policy state to determine whether changes would be made. Payloads that would be sent are logged with a |
Supports check mode. |
|
Support: full When run with |
Supports Ansible’s |
Notes
Note
Site scoping: use
useAllSites: trueto apply a policy to all enterprise sites, orsiteListName: "<name>"to scope it to a named site list. The module resolves the name to the portal site list ID and raises an error if it is not found.flexAlgois the flex-algo name that defines the SLA metric for path selection (e.g.test-all-cores,hestia-all-cores). Use/v1/data/assurance/flex-algosto list available values. Omit for block/protection policies. When specified, the name is validated against the flex-algos that exist in the enterprise; the module fails with an error listing the available values if it is not found.lanNamesis a list of LAN segment names (strings) that scope which segments the assurance policy applies to. Omit or leave empty to apply to all LAN segments. When specified, each name is validated against the LAN segments that exist in the enterprise; the module fails with an error listing the available values if any is not found.Under
apps, each entry represents one application to assure or block. UseprofileName(human-readable string such asGraphiant_AssuredorThreat_Blocked) to specify the assurance profile — the module resolves it to the corresponding integerbucketId. UsebuiltinAppId(Graphiant built-in application ID) orcustomAppId(enterprise custom application ID) to identify the application.useAllServers(bool) andservers(list of{ip, port, protocol}) further scope to specific back-end servers.App name validation and auto-fill: for each app the module looks up the app
namein its profile’s bucket (bucket-apps API, keyed byprofileName/bucketIdover a ~30-day window). It validates thenameexists in that bucket and auto-fillsisDomain,builtinAppId, andcustomAppIdfrom the matched bucket app when they are not provided (values you supply always take precedence). It also auto-fillsservers({ip, port, protocol}) from the bucket-app-servers telemetry when you do not provide any. If the bucket returns no apps for the window, the module fails with an error since the app name cannot be validated.Validation and telemetry auto-fill apply to new apps. When updating an existing policy, an app already present in it reuses its currently stored servers/hints for any field you did not set, and the telemetry lookup is skipped — so re-running
configurewith an unchanged config stays idempotent even though telemetry is time-windowed and can drift.
Examples
# Provide policies through the config file, the inline parameters, or both — at least one of
# data_assurance_config_file / DataAssurancePolicies / ContentFilterPolicies is required.
# Configure Data Assurance policies from a YAML file.
- name: Configure Data Assurance policies
graphiant.naas.graphiant_data_assurance:
operation: configure
data_assurance_config_file: "sample_data_assurance_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
detailed_logs: true
register: da_result
no_log: true
# Configure Data Assurance policies directly from module parameters (no config file).
- name: Configure Data Assurance policies inline
graphiant.naas.graphiant_data_assurance:
operation: configure
DataAssurancePolicies:
- name: assurance-policy-1
useAllSites: true
flexAlgo: test-all-cores
apps:
- name: tcp
profileName: General_Assured
useAllServers: true
ContentFilterPolicies:
- name: block-gambling
useAllSites: true
categories:
- Gambling
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
no_log: true
# Use a config file as the base and override one policy's field via module parameters.
- name: Configure from file with an inline override
graphiant.naas.graphiant_data_assurance:
operation: configure
data_assurance_config_file: "sample_data_assurance_policies.yaml"
DataAssurancePolicies:
- name: assurance-policy-1
flexAlgo: hestia-all-cores
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
no_log: true
# Flexible task — accept whichever source the caller supplies (file, inline, or both).
# Unset vars are dropped via default(omit) so only the provided source(s) are passed.
- name: Configure Data Assurance policies from any source
graphiant.naas.graphiant_data_assurance:
operation: configure
data_assurance_config_file: "{{ config_file | default(omit) }}"
DataAssurancePolicies: "{{ data_assurance_policies | default(omit) }}"
ContentFilterPolicies: "{{ content_filter_policies | default(omit) }}"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
no_log: true
# Deconfigure (delete) Data Assurance policies.
- name: Deconfigure Data Assurance policies
graphiant.naas.graphiant_data_assurance:
operation: deconfigure
data_assurance_config_file: "sample_data_assurance_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
detailed_logs: true
no_log: true
# Preview changes without pushing (check mode).
- name: Preview Data Assurance configure (dry run)
graphiant.naas.graphiant_data_assurance:
operation: configure
data_assurance_config_file: "sample_data_assurance_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
check_mode: true
register: da_preview
# Preview per-policy diffs (run playbook with --diff or set diff: true on the task).
- name: Preview Data Assurance policy changes
graphiant.naas.graphiant_data_assurance:
operation: configure
data_assurance_config_file: "sample_data_assurance_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
diff: true
register: da_diff
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Whether the operation modified at least one policy. In check mode ( Returned: always |
|
Policy names that were created or updated (when changed=true). Returned: when supported |
|
The config file used for the operation. Returned: always |
|
Policy names that were deleted (when deconfigure and changed=true). Returned: when supported |
|
Raw manager result details (includes Each Returned: when supported |
|
Ansible diff output when run with Built from Returned: when diff mode is enabled and |
|
Result message (includes detailed logs when enabled). Returned: always |
|
The operation performed. Returned: always |
|
Policy names that were skipped because desired state already matched. Returned: when supported |