cisco.intersight.intersight_vlan_policy_info module – Gather information about VLAN Policies and their VLANs in Cisco Intersight

Note

This module is part of the cisco.intersight collection (version 2.2.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 cisco.intersight.

To use it in a playbook, specify: cisco.intersight.intersight_vlan_policy_info.

Synopsis

  • Retrieve comprehensive information about VLAN Policies and their associated VLANs from Cisco Intersight.

  • Query policies by organization, policy name, or filter VLANs by name patterns.

  • Returns structured data combining policy metadata with detailed VLAN configurations.

  • Supports filtering by organization, policy name, and VLAN name.

  • If no filters are provided, all VLAN Policies and their VLANs will be returned.

  • Returns structured data with both policy information and associated VLAN details.

Parameters

Parameter

Comments

api_key_id

string / required

Public API Key ID associated with the private key.

If not set, the value of the INTERSIGHT_API_KEY_ID environment variable is used.

api_private_key

path / required

Filename (absolute path) or string of PEM formatted private key data to be used for Intersight API authentication.

If a string is used, Ansible vault should be used to encrypt string data.

Ex. ansible-vault encrypt_string –vault-id tme@/Users/dsoper/Documents/vault_password_file ‘—–BEGIN EC PRIVATE KEY—–

<your private key data>

—–END EC PRIVATE KEY—–’

If not set, the value of the INTERSIGHT_API_PRIVATE_KEY environment variable is used.

api_uri

string

URI used to access the Intersight API.

If not set, the value of the INTERSIGHT_API_URI environment variable is used.

Default: "https://intersight.com/api/v1"

name

string

The exact name of the VLAN Policy to retrieve information from.

When specified, only the matching policy and its VLANs will be returned.

Can be combined with vlan_name filter to get specific VLANs from a specific policy.

organization

string

The name of the organization to filter VLAN Policies by.

Use ‘default’ for the default organization.

When specified, only policies from this organization will be returned.

use_proxy

boolean

If no, it will not use a proxy, even if one is defined in an environment variable on the target hosts.

Choices:

  • false

  • true ← (default)

validate_certs

boolean

Boolean control for verifying the api_uri TLS certificate

Choices:

  • false

  • true ← (default)

vlan_name

string

Filter VLANs by name within the policies.

Can be used with or without policy name filtering.

Supports exact matching (e.g., “prod_100” will match only “prod_100”).

When combined with policy name, filters VLANs within that specific policy.

Examples

# Basic Usage Examples
- name: Fetch all VLAN Policies and their VLANs from all organizations
  cisco.intersight.intersight_vlan_policy_info:
    api_private_key: "{{ api_private_key }}"
    api_key_id: "{{ api_key_id }}"
  register: all_vlan_policies

# Organization-specific Examples
- name: Fetch all VLAN Policies from the default organization
  cisco.intersight.intersight_vlan_policy_info:
    api_private_key: "{{ api_private_key }}"
    api_key_id: "{{ api_key_id }}"
    organization: "default"
  register: default_org_policies

- name: Fetch all VLAN Policies from a custom organization
  cisco.intersight.intersight_vlan_policy_info:
    api_private_key: "{{ api_private_key }}"
    api_key_id: "{{ api_key_id }}"
    organization: "Engineering"
  register: engineering_policies

# Specific Policy Examples
- name: Fetch a specific VLAN Policy by name with all its VLANs
  cisco.intersight.intersight_vlan_policy_info:
    api_private_key: "{{ api_private_key }}"
    api_key_id: "{{ api_key_id }}"
    name: "datacenter-vlan-policy"
  register: specific_policy

- name: Display policy details
  debug:
    msg: "Policy {{ specific_policy.api_response.policy.Name }} has {{ specific_policy.api_response.vlans | length }} VLANs"

# VLAN Filtering Examples
- name: Find all policies containing a specific VLAN
  cisco.intersight.intersight_vlan_policy_info:
    api_private_key: "{{ api_private_key }}"
    api_key_id: "{{ api_key_id }}"
    vlan_name: "prod_100"
  register: policies_with_prod_100

- name: Find specific VLAN in a specific policy
  cisco.intersight.intersight_vlan_policy_info:
    api_private_key: "{{ api_private_key }}"
    api_key_id: "{{ api_key_id }}"
    name: "datacenter-vlan-policy"
    vlan_name: "mgmt_300"
  register: specific_vlan_in_policy

Return Values

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

Key

Description

api_response

dictionary

The API response containing policy and VLAN information.

Returns a dictionary when querying a single policy or no policies found.

Returns a list when multiple policies are found.

Returned: always

Sample: {"vlan_policy": {"Description": "VLAN policy for datacenter infrastructure", "Moid": "12345678901234567890abcd", "Name": "datacenter-vlan-policy", "ObjectType": "fabric.EthNetworkPolicy", "Organization": {"Name": "default", "ObjectType": "organization.Organization"}, "Tags": [{"Key": "Site", "Value": "DataCenter-A"}, {"Key": "Environment", "Value": "Production"}]}, "vlans": [{"AutoAllowOnUplinks": true, "IsNative": false, "Moid": "vlan12345678901234567890", "MulticastPolicy": {"Name": "default-multicast-policy", "ObjectType": "fabric.MulticastPolicy"}, "Name": "prod_100", "ObjectType": "fabric.Vlan", "SharingType": "None", "VlanId": 100}, {"AutoAllowOnUplinks": true, "IsNative": false, "Moid": "vlan09876543210987654321", "Name": "dmz_primary_50", "ObjectType": "fabric.Vlan", "PrimaryVlanId": 0, "SharingType": "Primary", "VlanId": 50}, {"AutoAllowOnUplinks": true, "IsNative": false, "Moid": "vlanabcdef1234567890123456", "Name": "dmz_isolated_51", "ObjectType": "fabric.Vlan", "PrimaryVlanId": 50, "SharingType": "Isolated", "VlanId": 51}]}

vlan_policy

dictionary

VLAN policy information

Returned: always

vlans

list / elements=string

List of VLANs associated with the policy

Returned: always

Authors

  • Ron Gershburg (@rgershbu)