graphiant.naas.graphiant_traffic_policy module – Manage device traffic policy rulesets and LAN segment attachments
Note
This module is part of the graphiant.naas collection (version 26.5.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_traffic_policy.
New in graphiant.naas 26.5.0
Synopsis
Configure or delete device-level traffic policy rulesets under
edge.trafficPolicy.trafficRulesets.Attach or detach a named ruleset on LAN segments under
edge.segments.<name>.trafficRuleset.ruleset.Reads a structured YAML config file and builds the raw device-config payload in Python.
The configure workflow applies rulesets (
operation=configure) and attaches them to LAN segments (operation=attach_to_lan_segments). The deconfigure workflow clears segment references (operation=detach_from_lan_segments) and deletes listed rulesets (operation=deconfigure).Configure is idempotent: compares intended rulesets to existing device state and skips push when already matched.
Deconfigure deletes only the rulesets listed in the YAML by setting
ruleset: nullper ruleset key.Under
configure, setstate: absenton a ruleset or individual rule in YAML to delete only that object (sendsruleset: nullorrule: nullin the payload). Omittedstatemeanspresent. This allows removing one rule without deconfiguring the whole ruleset.Attach/detach operations compare each listed segment’s ruleset reference to the device and skip when unchanged.
Requirements
The below requirements are needed on the host that executes this module.
python >= 3.7
graphiant-sdk >= 25.12.1
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 |
|
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 traffic policy rulesets.
Choices:
|
|
Path to the traffic policy YAML file. Can be an absolute path or relative to the configured config_path. Expected top-level key is Each device may define
|
|
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 configuration is pushed to devices, but the module still reads current device state to determine whether changes would be made. Payloads that would be pushed are logged with a |
Supports check mode. |
Notes
Note
One YAML file may define both
trafficRulesetsandsegments.configure/deconfigurereadtrafficRulesetsonly;attach_to_lan_segments/detach_from_lan_segmentsreadsegmentsonly. Run both steps for a full traffic policy lifecycle, or use the sample playbook tagsconfigureanddeconfigure, which run attach/detach together with ruleset configure/deconfigure.This module manages traffic policies directly on devices (device config API), not portal-only objects.
Configuration files support Jinja2 templating syntax for dynamic configuration generation.
Deconfigure payload uses
ruleset: nullper ruleset key; this module preserves nulls in the final payload pushed to the API.
Examples
# Configure workflow: rulesets, then attach to LAN segments (same YAML file).
- name: Configure device-level traffic policy rulesets
graphiant.naas.graphiant_traffic_policy:
operation: configure
traffic_policy_config_file: "sample_device_traffic_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
detailed_logs: true
register: traffic_policy_result
no_log: true
- name: Attach traffic ruleset to LAN segments
graphiant.naas.graphiant_traffic_policy:
operation: attach_to_lan_segments
traffic_policy_config_file: "sample_device_traffic_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
detailed_logs: true
# Deconfigure workflow: detach from LAN segments, then delete listed rulesets.
- name: Detach traffic ruleset from LAN segments
graphiant.naas.graphiant_traffic_policy:
operation: detach_from_lan_segments
traffic_policy_config_file: "sample_device_traffic_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
detailed_logs: true
- name: Deconfigure device-level traffic policy rulesets
graphiant.naas.graphiant_traffic_policy:
operation: deconfigure
traffic_policy_config_file: "sample_device_traffic_policies.yaml"
host: "{{ graphiant_host }}"
username: "{{ graphiant_username }}"
password: "{{ graphiant_password }}"
detailed_logs: true
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Whether the operation would push config to at least one device. In check mode ( Returned: always |
|
Device names where configuration was pushed (when changed=true). Returned: when supported |
|
Result message (includes detailed logs when enabled). Returned: always |
|
The operation performed. Returned: always |
|
Device names that were skipped because desired state already matched. Returned: when supported |
|
The traffic policy config file used for the operation. Returned: always |