graphiant.naas.graphiant_ospfv2 module – Manage Graphiant OSPFv2 configuration (edge.segments.*.ospfv2)

Note

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

New in graphiant.naas 26.7.0

Synopsis

  • Configure or delete OSPFv2 processes under edge segments (edge.segments.<segment>.ospfv2).

  • Reads a structured YAML config file and builds the raw device-config payload in Python.

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

Requirements

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

  • python >= 3.7

  • graphiant-sdk >= 26.7.0 (required for OSPFv2 interface MD5 authentication support)

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.

Choices:

  • false ← (default)

  • true

host

aliases: base_url

string / required

Graphiant portal host URL for API connectivity.

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

operation

string

Specific operation to perform.

configure builds full OSPF process objects.

deconfigure deletes OSPF processes for listed segments.

Choices:

  • "configure"

  • "deconfigure"

ospfv2_config_file

aliases: ospf_config_file

string / required

Path to the ospf YAML file.

Can be an absolute path or relative to the configured config_path.

Expected top-level key is networkLists and portLists (list of devices).

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.

state

string

Desired state for OSPF processes.

present maps to configure; absent maps to deconfigure if operation not set

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.

vault_ospf_md5_passwords

dictionary

Dict of device name to interface name to OSPF MD5 authentication key (configure only). Pass from playbook vars loaded from encrypted vault_secrets.yml; secrets in memory only.

Keys must match the device name and interfaceName under that device’s areas/interfaces in the OSPF config. Optional; used only when an interface’s authentication.key is null in YAML.

Default: {}

Attributes

Attribute

Support

Description

check_mode

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 [check_mode] prefix.

Supports check mode.

diff_mode

Support: full

When the playbook runs with --diff and a device would change, the module returns a diff dictionary (before / after strings). Structured entries are also in details.diff_plan.

Supports Ansible’s --diff for pending traffic policy list updates.

Notes

Note

  • OSPF Operations:

  • - Configure: Create/update OSPFv2 processes listed in the config.

  • - Deconfigure: Delete OSPFv2 processes listed in the config.

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

  • The module automatically resolves device names to IDs.

  • YAML schema uses camelCase keys (for example: staticRoutes, lanSegment, destinationPrefix, nextHops).

  • Vault (configure only): vault_ospf_md5_passwords.

  • Use encrypted configs/vault_secrets.yml, configs/vault-password-file.sh; no plaintext.

  • Load with ansible.builtin.include_vars (no_log true); pass the dict so secrets stay in memory.

  • Vault keys are device name -> interfaceName. Leave authentication.key null in YAML to fill it from vault. See configs/vault_secrets.yml.example.

  • Configure idempotency: compares intended routes to existing device state per segment + prefix; skips push when already matched (changed=false).

  • Deconfigure deletes only the prefixes listed in the YAML (per segment).

  • Deconfigure payload uses route: null per prefix; this module preserves nulls in the final payload pushed to the API.

Examples

- name: Configure OSPF
  graphiant.naas.graphiant_ospfv2:
    operation: configure
    ospfv2_config_file: "sample_ospfv2_config.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    detailed_logs: true
    state: present
  register: ospfv2_result
  no_log: true

- name: Display result message (includes detailed logs)
  ansible.builtin.debug:
    msg: "{{ ospfv2_result.msg }}"

- name: Configure OSPF with MD5 auth keys from Ansible Vault (leave authentication.key null in YAML)
  graphiant.naas.graphiant_ospfv2:
    operation: configure
    ospfv2_config_file: "sample_ospfv2_config.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    vault_ospf_md5_passwords: "{{ vault_ospf_md5_passwords | default({}) }}"
    state: present
  register: ospfv2_result

- name: Deconfigure OSPF (deletes only OSPF processes listed in YAML)
  graphiant.naas.graphiant_ospfv2:
    operation: deconfigure
    ospfv2_config_file: "sample_ospfv2_config.yaml"
    host: "{{ graphiant_host }}"
    username: "{{ graphiant_username }}"
    password: "{{ graphiant_password }}"
    detailed_logs: true
    state: absent
  no_log: true

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.

true when config would be pushed to at least one device; false when intended state already matched.

In check mode (--check), no configuration is pushed, but changed reflects whether changes would be made.

Returned: always

Sample: false

configured_devices

list / elements=string

Device names where configuration was pushed (when changed=true).

Returned: when supported

Sample: ["edge-1-sdktest"]

details

dictionary

Raw manager result details (includes changed/configured/skipped device lists).

Returned: when supported

diff

dictionary

Ansible --diff payload showing per-device before/after OSPF state.

Returned: when playbook uses --diff and at least one device would be updated

msg

string

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

Returned: always

Sample: "OSPF processes already match desired state; no changes needed"

operation

string

The operation performed.

Returned: always

Sample: "configure"

ospfv2_config_file

string

The OSPFv2 config file used for the operation.

Returned: always

Sample: "sample_ospfv2_config.yaml"

skipped_devices

list / elements=string

Device names that were skipped because desired state already matched.

Returned: when supported

Sample: ["edge-1-sdktest"]

Authors

  • Graphiant Team (@graphiant)