graphiant.naas.graphiant_sites module – Manage Graphiant sites and object attachments

Note

This module is part of the graphiant.naas collection (version 26.3.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_sites.

New in graphiant.naas 25.11.0

Synopsis

  • This module provides comprehensive site management capabilities for Graphiant Edge devices.

  • Supports site creation and deletion.

  • Enables attachment and detachment of global system objects to/from sites.

  • Can perform site-only operations or object attachment operations independently.

  • All operations use Jinja2 templates for consistent configuration deployment.

  • Configuration files support Jinja2 templating for dynamic generation.

Requirements

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

  • python >= 3.7

  • graphiant-sdk >= 26.3.0

Parameters

Parameter

Comments

access_token

string

Bearer token for API authentication (for example, from graphiant login, which opens a browser for sign-in (SSO or non-SSO) and retrieves the token).

If not passed as a module argument, the collection reads GRAPHIANT_ACCESS_TOKEN (set after graphiant login when you source ~/.graphiant/env.sh).

When a bearer token is present (module argument or environment), it takes precedence over username and password.

If no valid token is available, the module authenticates with username and password when both are supplied.

detailed_logs

boolean

Enable detailed logging output for troubleshooting and monitoring.

When enabled, provides comprehensive logs of all site operations.

Logs are captured and included in the result_msg for display using ansible.builtin.debug module.

Choices:

  • false ← (default)

  • true

host

aliases: base_url

string / required

Graphiant portal host URL for API connectivity.

Example: “https://api.graphiant.com

operation

string

The specific site operation to perform.

configure: Create sites and attach global objects in one operation.

deconfigure: Detach global objects and delete sites in one operation.

configure_sites: Create sites only (without attaching objects).

deconfigure_sites: Delete sites only (without detaching objects).

attach_objects: Attach global objects to existing sites.

detach_objects: Detach global objects from sites (without deleting sites).

Choices:

  • "configure"

  • "deconfigure"

  • "configure_sites"

  • "deconfigure_sites"

  • "attach_objects"

  • "detach_objects"

password

string

Graphiant portal password for authentication.

Required for password-based login when no valid bearer token is available from access_token or GRAPHIANT_ACCESS_TOKEN.

site_config_file

string / required

Path to the site configuration YAML file.

Required for all operations.

Can be an absolute path or relative path. Relative paths are resolved using the configured config_path.

Configuration files support Jinja2 templating syntax for dynamic generation.

File must contain site definitions with site names and global object attachments.

state

string

The desired state of the sites.

present: Maps to configure when operation not specified.

absent: Maps to deconfigure when operation not specified.

Choices:

  • "present" ← (default)

  • "absent"

username

string

Graphiant portal username for authentication.

Required for password-based login when no valid bearer token is available from access_token or GRAPHIANT_ACCESS_TOKEN.

Attributes

Attribute

Support

Description

check_mode

Support: full

When run with --check, the module logs the exact payloads that would be pushed with a [check_mode] prefix so you can see what configuration would be applied. The module does not perform state comparison, so changed may be True even when the configuration is already applied.

Supports check mode. In check mode, no configuration is pushed to the devices but payloads that would be pushed are logged with [check_mode].

Notes

Note

  • Check mode (--check): No config is pushed; payloads that would be pushed are logged with [check_mode].

  • Use playbook playbooks/site_management.yml with tags configure_sites, deconfigure_sites,

  • attach_objects, detach_objects, configure, deconfigure.

  • Site Operations:

  • - configure: Create sites and attach global objects in one operation.

  • - deconfigure: Detach global objects and delete sites in one operation.

  • - configure_sites: Create sites only (without attaching objects).

  • - deconfigure_sites: Delete sites only (without detaching objects).

  • - attach_objects: Attach global objects to existing sites. Prerequisite: global objects created first.

  • - detach_objects: Detach global objects from sites (sites remain).

  • Configuration files support Jinja2 templating syntax for dynamic configuration generation.

  • The module automatically resolves site names and global object names to IDs.

  • All operations are idempotent and safe to run multiple times.

  • Global objects must be created using graphiant.naas.graphiant_global_config module before attaching to sites.

See Also

See also

graphiant.naas.graphiant_global_config

Configure global objects (LAN segments, prefix sets, etc.) that can be attached to sites

graphiant.naas.graphiant_data_exchange

Use sites in Data Exchange service configurations

Examples

- name: Configure sites (create sites and attach objects)
  graphiant.naas.graphiant_sites:
    operation: configure
    site_config_file: "sample_sites.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    detailed_logs: true
  register: sites_result

- name: Create sites only
  graphiant.naas.graphiant_sites:
    operation: configure_sites
    site_config_file: "sample_sites.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    detailed_logs: true

- name: Attach global objects to existing sites
  graphiant.naas.graphiant_sites:
    operation: attach_objects
    site_config_file: "sample_site_attachments.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    detailed_logs: true

- name: Detach global objects from sites
  graphiant.naas.graphiant_sites:
    operation: detach_objects
    site_config_file: "sample_site_attachments.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    detailed_logs: true

- name: Delete sites only
  graphiant.naas.graphiant_sites:
    operation: deconfigure_sites
    site_config_file: "sample_sites.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"

- name: Deconfigure sites (detach objects and delete sites)
  graphiant.naas.graphiant_sites:
    operation: deconfigure
    site_config_file: "sample_sites.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"

- name: Configure sites using state parameter
  graphiant.naas.graphiant_sites:
    state: present
    site_config_file: "sample_sites.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"

Return Values

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

Key

Description

changed

boolean

Whether the operation made changes to the system.

true for all configure/deconfigure/attach/detach operations.

Returned: always

Sample: true

msg

string

Result message from the operation, including detailed logs when detailed_logs is enabled.

Returned: always

Sample: "Successfully configured (created sites and attached objects)"

operation

string

The operation that was performed.

One of configure, deconfigure, configure_sites, deconfigure_sites, attach_objects, or detach_objects.

Returned: always

Sample: "configure"

site_config_file

string

The site configuration file used for the operation.

Returned: always

Sample: "sample_sites.yaml"

Authors

  • Graphiant Team (@graphiant)