### Setup Wireless Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/MANIFEST.txt Example for setting up wireless networks. Refer to data-model.md for wireless configuration and resource-reference.md for wireless resources. An additional SSID example is available in outputs-and-examples.md. ```yaml wireless: ssid: "MyWiFi" security: "WPA2PSK" password: "securepassword" ``` -------------------------------- ### Minimal Configuration Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This is a minimal configuration example for the Catalyst Center NAC module. It is the fastest path for new users to get started. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a ``` -------------------------------- ### Output Configuration for Documentation Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example demonstrates how to output the configuration for documentation purposes using the Catalyst Center NAC module. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a output_configuration: enabled: true ``` -------------------------------- ### Understanding Defaults Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/MANIFEST.txt Example illustrating how default values are applied. Refer to architecture-and-patterns.md for details on defaults. ```yaml defaults_example: setting: "value" ``` -------------------------------- ### Example Complete Configuration File Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/data-model.md A comprehensive example demonstrating a full Catalyst Center configuration, including site hierarchy, network settings, and device credentials. ```yaml --- catalyst_center: defaults: catalyst_center: sites: floors: height: 5 sites: global: network_settings: network: network_default areas: - name: Europe parent_name: Global network_settings: network: europe_network cli_credentials: europe_cli - name: Americas parent_name: Global cli_credentials: americas_cli buildings: - name: Paris parent_name: Global/Europe country: France latitude: 48.8566 longitude: 2.3522 address: "Paris, France" - name: London parent_name: Global/Europe country: "United Kingdom" latitude: 51.5074 longitude: -0.1278 floors: - name: Floor1 parent_name: Global/Europe/Paris floor_number: 1 width: 100 length: 150 network_settings: device_credentials: cli_credentials: - name: europe_cli username: admin password: ${var.cli_password} enable: ${var.enable_password} network: - name: network_default ntp_servers: - 8.8.8.8 - 8.8.4.4 domain_name: example.com dns_servers: - 8.8.8.8 timezone: Europe/Paris - name: europe_network ntp_servers: - 8.8.8.8 ``` -------------------------------- ### Configure Fabric Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/MANIFEST.txt Example for configuring network fabric. Consult data-model.md for fabric details and resource-reference.md for fabric resources. ```yaml fabric: name: "Fabric 1" description: "Main production fabric" ``` -------------------------------- ### Add a New Site Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/MANIFEST.txt Example demonstrating how to add a new site. Refer to data-model.md for site data structure and resource-reference.md for area, building, and floor resources. ```yaml sites: - name: "Site A" area: "Area 1" building: "Building 1" floor: "Floor 1" ``` -------------------------------- ### Apply Defaults with Try Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Example of applying default values using 'try()'. This attempts to get a value from 'each.value.port', falling back to a default defined in 'local.defaults'. ```hcl # Apply defaults with try() port = try(each.value.port, local.defaults.catalyst_center.network_settings.device_credentials.https_read_credentials.port, null) ``` -------------------------------- ### Network Settings with Credentials Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example demonstrates configuring network settings including credentials for sites managed by the Catalyst Center NAC module. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a network: settings: name: Site A Network Settings type: general ntp_servers: - 1.pool.ntp.org dns_servers: - 8.8.8.8 snmp_v3_credentials: name: snmp_v3_creds auth_protocol: sha privacy_protocol: aes user: snmpuser auth_password: MySecurePassword privacy_password: MySecurePassword ``` -------------------------------- ### Terraform Commands for Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/examples/site/README.md Initialize, plan, and apply the Terraform configuration to create resources. ```bash $ terraform init $ terraform plan $ terraform apply ``` -------------------------------- ### Complete Minimum Example for Catalyst Center NAC Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md This example demonstrates a minimal Terraform setup for Cisco Catalyst Center NAC. It includes provider configuration, module instantiation, and an output for managed sites. Ensure you have Terraform 1.9.0+ and the Cisco Catalyst Center provider installed. ```hcl # versions.tf terraform { required_version = ">= 1.9.0" required_providers { catalystcenter = { source = "CiscoDevNet/catalystcenter" version = "~> 0.5.16" } } } provider "catalystcenter" { username = "admin" password = "password" url = "https://10.0.0.1" } # main.tf module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "~> 0.4.3" yaml_files = ["${path.module}/config.yaml"] } output "sites" { value = module.catalystcenter.sites } # config.yaml --- catalyst_center: sites: areas: - name: Site1 parent_name: Global ``` ```bash terraform init terraform apply terraform output sites ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md This example demonstrates a complete configuration for the Catalyst Center NAC module, including input sources, site management, performance options, and output settings. Ensure all required input sources are correctly specified. ```hcl module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "~> 0.4.3" # Input sources yaml_directories = ["./config"] yaml_files = ["./overrides.yaml"] # Site management managed_sites = ["Global/Europe", "Global/Americas"] manage_specific_sites_only = false manage_global_settings = true # Performance options use_bulk_api = true bulk_site_provisioning = "Global/Europe" # Output options write_default_values_file = "${path.module}/applied-defaults.yaml" } output "catalyst_center_model" { value = module.catalystcenter.model } output "managed_sites" { value = module.catalystcenter.sites } ``` -------------------------------- ### Fabric and Wireless Configuration Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example shows how to configure fabric and wireless settings for sites using the Catalyst Center NAC module. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a fabric: enabled: true bgp_peering: asn: 65001 wireless: enabled: true ssids: - name: MyWiFi security: WPA2_ENTERPRISE radius_server: 192.168.1.100 radius_port: 1812 radius_secret: MyRadiusSecret ``` -------------------------------- ### Multi-Region Management Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/MANIFEST.txt Example for multi-region management. Refer to configuration.md for `managed_sites` and architecture-and-patterns.md for site filtering. ```yaml multi_region: managed_sites: - "Site A" - "Site B" ``` -------------------------------- ### Multi-Region Selective Management Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example demonstrates a multi-region deployment with selective management of sites using the Catalyst Center NAC module. ```yaml sites: - name: Site A region: US-East physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a - name: Site B region: US-West physical: address: 456 Oak Ave city: Othertown state: OR zip: 97005 country: US management: ip_address: 192.168.2.1 credentials_id: creds_b management: regions: US-East: enabled: true US-West: enabled: false ``` -------------------------------- ### Generate and Review Defaults Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example shows how to generate and review default values for the Catalyst Center NAC module configuration. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a review_defaults: enabled: true ``` -------------------------------- ### Large Deployment Optimization Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/MANIFEST.txt Example for optimizing large deployments. Refer to architecture-and-patterns.md for performance tips and configuration.md for `use_bulk_api`. ```yaml deployment_optimization: use_bulk_api: true ``` -------------------------------- ### Conditional Configuration with Overrides Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example demonstrates conditional configuration and overrides for specific sites using the Catalyst Center NAC module. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a settings: ntp_servers: - 1.pool.ntp.org - name: Site B physical: address: 456 Oak Ave city: Othertown state: OR zip: 97005 country: US management: ip_address: 192.168.2.1 credentials_id: creds_b settings: ntp_servers: - pool.ntp.org dns_servers: - 8.8.4.4 conditional_settings: - condition: "site.name == 'Site B'" overrides: ntp_servers: - override.pool.ntp.org ``` -------------------------------- ### Bulk API for Large Deployments Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This example shows how to use the bulk API for large deployments with the Catalyst Center NAC module. It is designed for performance. ```yaml sites: - name: Site A physical: address: 123 Main St city: Anytown state: CA zip: 90210 country: US management: ip_address: 192.168.1.1 credentials_id: creds_a - name: Site B physical: address: 456 Oak Ave city: Othertown state: OR zip: 97005 country: US management: ip_address: 192.168.2.1 credentials_id: creds_b # ... (many more sites) bulk_operations: enabled: true ``` -------------------------------- ### Device Name to ID Example Map Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md An example of the output from the device_name_to_id local, mapping hostnames to unique device identifiers. ```hcl { "router-paris-1" = "device-id-123", "router-paris-2" = "device-id-124", "router-london-1" = "device-id-125" } ``` -------------------------------- ### Example Output of Applied Defaults Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md An excerpt from the 'applied-defaults.yaml' file, showing default configurations for sites, network settings, and wireless parameters. ```yaml defaults: catalyst_center: sites: areas: parent_name: Global floors: height: 3 length: 30 width: 30 rf_model: Cubes And Walled Offices units_of_measure: feet network_settings: device_credentials: https_read_credentials: port: 443 wireless: ap_profiles: client_limit: 0 time_zone: Not Configured ``` -------------------------------- ### Default Merging Process Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This code snippet illustrates the default merging process, showing how defaults are applied to configurations. ```python def merge_defaults(config, defaults): # Merge default values into the main configuration merged_config = apply_defaults(config, defaults) return merged_config ``` -------------------------------- ### Resource Generation Pattern Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This code snippet demonstrates a resource generation pattern used within the module. ```python def generate_resource(resource_type, config): # Generate a specific resource based on configuration if resource_type == 'site': return create_site_resource(config) # ... other resource types return None ``` -------------------------------- ### Dependency Management Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This code snippet illustrates explicit dependency management within the module. ```python def build_dependency_graph(resources): # Build a graph representing resource dependencies graph = create_graph(resources) return graph ``` -------------------------------- ### Minimum Configuration Error Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Illustrates the error message displayed when none of the required configuration inputs (yaml_directories, yaml_files, or model) are provided. ```hcl Error: Precondition failed Either `yaml_directories`,`yaml_files` or a non-empty `model` value must be provided. ``` -------------------------------- ### Network Settings with Credentials Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md Configure network settings and device credentials using YAML files. This example shows how to define NTP servers, DHCP servers, domain names, DNS servers, and device credentials for CLI and SNMP. ```yaml --- catalyst_center: sites: areas: - name: Europe parent_name: Global network_settings: network: europe_network cli_credentials: europe_cli network_settings: network: - name: europe_network ntp_servers: - 8.8.8.8 - 8.8.4.4 dhcp_servers: - 10.0.0.1 domain_name: example.com dns_servers: - 8.8.8.8 - 1.1.1.1 timezone: Europe/Paris device_credentials: cli_credentials: - name: europe_cli username: admin password: "${var.cli_password}" enable: "${var.enable_password}" snmpv3_credentials: - name: snmpv3_user username: snmpadmin auth_type: SHA auth_password: "${var.snmp_auth_password}" privacy_type: AES128 privacy_password: "${var.snmp_privacy_password}" ``` -------------------------------- ### Get All Sites Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Retrieves all pre-existing sites in the network. No filters are applied. ```hcl data "catalystcenter_sites" "all_sites" { # No filters - returns all sites } ``` -------------------------------- ### Site Filtering Mode Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This code snippet demonstrates one of the site filtering modes used in the module. ```python def filter_sites(all_sites, mode): # Filter sites based on the specified mode if mode == 'managed': return [s for s in all_sites if s.is_managed] # ... other modes return all_sites ``` -------------------------------- ### L3 Virtual Networks Example Map Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md An example of the L3 virtual networks map, showing virtual network names and the fabric sites/zones they are enabled on. ```hcl { "VN1" = ["Global/Europe", "Global/Americas"], "VN2" = ["Global/Europe/France", "Global/Americas/USA"], "VN_Management" = ["Global"] } ``` -------------------------------- ### Access Catalyst Center Sites using Shorthand Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Example demonstrating the usage of the 'catalyst_center' local value shorthand to access site areas, making the code more concise. ```hcl # Instead of: local.model.catalyst_center.sites.areas for area in try(local.catalyst_center.sites.areas, []) ``` -------------------------------- ### Count Devices from Model Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Example of counting the number of devices defined in the 'model' local value. Uses 'try()' to safely access the 'devices' key. ```hcl # Count devices length(try(local.model.catalyst_center.inventory.devices, [])) ``` -------------------------------- ### Configure IP Pool via Module Usage Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Example of configuring an IP address pool using a module's input variables. This demonstrates how to define pool settings like name, IP address space, range, and gateway. ```yaml network_settings: ip_pools: - name: management_pool ip_address_space: IPv4 ip_pool_start: 10.0.1.10 ip_pool_end: 10.0.1.254 gateway: 10.0.1.1 ``` -------------------------------- ### SSID Radio Type Usage Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Demonstrates how to use the ssid_radio_type_mapping local to translate user input into API-compatible values for SSID radio types. ```hcl ssid_radio_type = try( local.ssid_radio_type_mapping[each.value.ssid_radio_type], local.defaults.catalyst_center.wireless.ssids.ssid_radio_type, null ) ``` -------------------------------- ### Configure Bulk Site Provisioning Path Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md When `use_bulk_api` is enabled, specify a site path to provision all devices under that site and its children in a single bulk operation. The path must start with 'Global' and have a maximum of 5 hierarchy levels. ```hcl variable "bulk_site_provisioning" { description = "Site path for bulk device provisioning. When set with use_bulk_api=true, provisions all devices from this site and all child sites in a single bulk operation. Example: 'Global/Poland' will provision all devices under Poland hierarchy." type = string default = null validation { condition = var.bulk_site_provisioning == null || var.use_bulk_api == true error_message = "The bulk_site_provisioning variable can only be used when use_bulk_api is set to true." } validation { condition = ( var.bulk_site_provisioning == null || ( var.use_bulk_api == true && can(regex("^Global(\/[^/]+)*$", var.bulk_site_provisioning)) && can(length(regexall("/", var.bulk_site_provisioning)) <= 4) ) ) error_message = "The bulk_site_provisioning must be a valid site hierarchy path starting with 'Global' (e.g., 'Global/Poland' or 'Global/Area1/Area2') with a maximum of 5 levels." } } ``` ```hcl module "catalystcenter" { use_bulk_api = true bulk_site_provisioning = "Global/Poland" # Provisions all devices under Poland } ``` -------------------------------- ### Configure Wireless SSID Module Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Example of configuring wireless SSIDs within a module, specifying name, authentication type, and broadcast settings. ```yaml wireless: ssids: - name: CorporateNet auth_type: ENTERPRISE wlan_type: enterprise broadcast_ssid: true ``` -------------------------------- ### Configure AP Profile Module Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Example of configuring AP profiles within a module, including name, remote worker status, SSH enablement, and client limit. ```yaml wireless: ap_profiles: - name: StandardProfile remote_worker_enabled: false ssh_enabled: true client_limit: 250 ``` -------------------------------- ### Instantiate Catalyst Center Module with YAML File Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/README.md Use the Catalyst Center Terraform module by specifying the path to a YAML configuration file. This example integrates the 'area.yaml' file into the Terraform configuration. ```hcl module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "0.4.3" yaml_files = ["area.yaml"] } ``` -------------------------------- ### Access Site Areas from Model Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Example of accessing site areas from the 'model' local value. Uses 'try()' for safe access to potentially missing keys. ```hcl # Access areas from configuration for area in try(local.model.catalyst_center.sites.areas, []) ``` -------------------------------- ### Site Hierarchy Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/INDEX.md Illustrates the hierarchical structure for site management within the Catalyst Center NAC module. This structure supports up to 9 levels deep. ```plaintext Global (root) ├── Area (1st level) │ ├── Area (2nd level) │ │ └── Building (can be at any level) │ │ └── Floor (lowest level) │ └── Building │ └── Floor └── Area └── Building └── Floor ``` -------------------------------- ### Fabric and Wireless Configuration Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md Configure fabric settings including L3 virtual networks and transits, as well as wireless settings like AP profiles, RF profiles, and SSIDs. This example demonstrates advanced fabric and wireless deployments. ```yaml --- catalyst_center: fabric: l3_virtual_networks: - name: VN1 anchor_site: Global/Europe - name: VN2 anchor_site: Global/Americas transits: - name: Transit_IP_Based type: IP_BASED_TRANSIT routing_protocol_name: BGP autonomous_system_number: 65001 fabric_sites: - name: Global/Europe pub_sub_enabled: false authentication_template: name: No Authentication l3_virtual_networks: - VN1 anycast_gateways: - ip_pool_name: vn1_pool vlan_id: 100 traffic_type: DATA layer2_flooding: false - name: Global/Americas pub_sub_enabled: false l3_virtual_networks: - VN2 anycast_gateways: - ip_pool_name: vn2_pool vlan_id: 200 wireless: ap_profiles: - name: StandardProfile description: "Standard AP Configuration" remote_worker_enabled: false ssh_enabled: true client_limit: 250 time_zone: "Europe/Paris" rf_profiles: - name: Standard5GHz enable_radio_type_a: true enable_radio_type_b: true radio_type_a_parent_profile: "Cisco-5GHz-Default" ssids: - name: CorporateNet auth_type: ENTERPRISE wlan_type: enterprise broadcast_ssid: true profile_name: StandardProfile - name: GuestNet auth_type: OPEN wlan_type: guest broadcast_ssid: true ``` -------------------------------- ### Check if Default Exists Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Example of checking if a default value exists using 'try()'. This attempts to retrieve 'each.value.height', falling back to a default from 'local.defaults'. ```hcl # Check if default exists height = try(each.value.height, local.defaults.catalyst_center.sites.floors.height, null) ``` -------------------------------- ### Conditional Site List Implementation Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/architecture-and-patterns.md Implement the site management logic using a conditional expression based on `manage_specific_sites_only`. The `matches_prefix` logic determines if a site path starts with any of the managed site prefixes. ```hcl sites = var.manage_specific_sites_only ? var.managed_sites : concat( [for site in areas if matches_prefix], [for site in buildings if matches_prefix], [for site in floors if matches_prefix] ) # where matches_prefix checks: anytrue([ for prefix in var.managed_sites : startswith(site_path, prefix) ]) ``` -------------------------------- ### Apply with Overrides Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md Apply the configuration with specific environment and override model variables. The override demonstrates changing network settings. ```bash terraform apply \ -var environment=production \ -var 'override_model={catalyst_center={network_settings={network=[{name="prod_override",ntp_servers=["1.1.1.1"]}]}}}' ``` -------------------------------- ### Error Handling Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This code snippet shows error handling and validation mechanisms within the module. ```python def process_request(request): try: # Process the request result = perform_operation(request) return result except Exception as e: # Handle errors gracefully log_error(e) return None ``` -------------------------------- ### Get All Network Devices Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Retrieves all network devices in the fabric. This is used for name-to-ID mapping. ```hcl data "catalystcenter_network_devices" "all_devices" { # No filters - returns all devices } ``` -------------------------------- ### Minimal Configuration with YAML File Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md Demonstrates a minimal Catalyst Center NAC module configuration using a YAML file for site definitions. Includes Terraform commands for initialization, planning, and applying. ```yaml --- catalyst_center: sites: areas: - name: Europe parent_name: Global - name: Americas parent_name: Global buildings: - name: Paris parent_name: Global/Europe country: France latitude: 48.8566 longitude: 2.3522 ``` ```hcl module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "~> 0.4.3" yaml_files = ["${path.module}/config/sites.yaml"] } output "sites" { value = module.catalystcenter.sites } ``` ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Get Global Site Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Retrieves the Global site ID. Use this to create top-level areas. ```hcl data "catalystcenter_site" "global" { name_hierarchy = "Global" } ``` -------------------------------- ### Validation Stage Check Example Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/README.md This code snippet represents a validation check within the module's validation stages. ```python def validate_configuration(config): # Perform validation checks on the configuration if not is_valid(config): raise ValidationError("Invalid configuration") return True ``` -------------------------------- ### Add Device to Plug and Play Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Adds a device to the Plug and Play onboarding process. Requires serial number, device name, and device type. Optional fields include image URL, config ID, and project ID. ```hcl resource "catalystcenter_pnp_device" "device1" { serial_number = "ABC123456789" device_name = "router-paris-1" device_type = "Cisco Catalyst 8200" image_url = "http://example.com/ios.bin" } ``` -------------------------------- ### Create CLI Credentials Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Define CLI credentials for device access, including username, password, and optionally an enable password. A description is required. ```hcl resource "catalystcenter_credentials_cli" "admin" { description = "admin_cli" username = "admin" password = var.cli_password enable_password = var.enable_password } ``` ```yaml network_settings: device_credentials: cli_credentials: - name: admin_cli username: admin password: ${var.cli_password} enable: ${var.enable_password} ``` -------------------------------- ### Get Fabric Sites Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Maps site IDs to fabric site IDs. This is essential for virtual network operations. ```hcl data "catalystcenter_fabric_sites" "fabric_sites" { } ``` -------------------------------- ### Create a Catalyst Center Project Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Use this resource to create a new project for organizing configuration templates. Ensure a unique name is provided. ```hcl resource "catalystcenter_project" "devices" { name = "Device Templates" description = "Standard device configurations" } ``` -------------------------------- ### Access Configuration Areas in Code Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md Demonstrates how to access specific configuration areas like site areas and network settings from the module's model output within local variables. ```hcl locals { # Access areas from output areas = try(module.catalystcenter.model.catalyst_center.sites.areas, []) # Access network settings network_settings = try(module.catalystcenter.model.catalyst_center.network_settings, {}) # Count created resources total_sites = length(module.catalystcenter.sites) } ``` -------------------------------- ### Deploy a Catalyst Center Template to Devices Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Deploy a previously created template to specified devices. Template parameters can be passed to customize the configuration. The `force_push` option can be used to override existing configurations. ```hcl resource "catalystcenter_deploy_template" "deploy_snmp" { template_id = catalystcenter_template.snmp.id device_ids = [data.catalystcenter_network_devices.all.devices[0].id] parameters = { snmp_community = "public" snmp_server = "10.0.0.1" } } ``` -------------------------------- ### Check Fabric Enabled in Model Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Example of checking if the 'fabric' key exists within the 'model' local value. Uses 'contains()' and 'keys()' for this check. ```hcl # Check fabric enabled contains(keys(local.model.catalyst_center), "fabric") ``` -------------------------------- ### Configure DNS Settings Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Set up DNS settings for a site, including the domain name and a list of DNS servers. The site ID is required. ```hcl resource "catalystcenter_dns_settings" "dns" { site_id = data.catalystcenter_site.global.id domain_name = "example.com" dns_servers = ["8.8.8.8", "1.1.1.1"] } ``` -------------------------------- ### Get IP Pools Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Looks up IP pool IDs by name. This data source retrieves information about all available IP pools. ```hcl data "catalystcenter_ip_pools" "all_ip_pools" { } ``` -------------------------------- ### Specify Template Directories Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Provide a list of paths to directories containing template files. These templates will be used by the module for configuration. ```hcl variable "templates_directories" { description = "List of paths to templates directories." type = list(string) default = [] } ``` ```hcl module "catalystcenter" { templates_directories = ["./templates", "./composites"] } ``` -------------------------------- ### Combine Pre-existing and Created Sites with Data Sources Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/architecture-and-patterns.md Use data sources to fetch both pre-existing and newly created sites. Merge the results to allow resources to reference sites from previous or current Terraform runs. ```hcl data "catalystcenter_sites" "all_sites" {} data "catalystcenter_sites" "created_sites" { depends_on = [ catalystcenter_floor.floor, catalystcenter_building.building, # ... all site creation resources ] } # Usage combines both local.combined_sites = merge( { for site in data.catalystcenter_sites.all_sites.sites : site.site_name_hierarchy => site }, { for site in data.catalystcenter_sites.created_sites.sites : site.site_name_hierarchy => site } ) ``` -------------------------------- ### Get Created Sites Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Queries sites created in the current Terraform run. This is useful for fallback scenarios and depends on site creation resources. ```hcl data "catalystcenter_sites" "created_sites" { # Depends on all site creation resources depends_on = [catalystcenter_floor.floor, ...] } ``` -------------------------------- ### Missing Sites Error Local Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Generates a user-friendly error message when managed sites specified in the configuration are not found in the YAML definition. Guides user action. ```hcl locals { missing_sites_error = length(local.missing_managed_sites) > 0 ? "❌ The following sites specified in managed_sites are not found in YAML configuration:\n\n${join("\n", [for s in local.missing_managed_sites : " • ${s}"])}\n\nAction required: ..." : "" } ``` -------------------------------- ### catalystcenter_transit_network Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Creates transit connectivity between fabric sites. This resource facilitates the setup of transit networks, supporting IP-based and LISP transit with configurable routing protocols. ```APIDOC ## catalystcenter_transit_network ### Description Creates transit connectivity between fabric sites. This resource facilitates the setup of transit networks, supporting IP-based and LISP transit with configurable routing protocols. ### Parameters #### Path Parameters - `name` (string) - Required - Transit network name - `type` (string) - Optional - Default: "IP_BASED_TRANSIT" - Transit type - `routing_protocol_name` (string) - Optional - Default: "BGP" - Routing protocol (IP transit) - `autonomous_system_number` (integer) - Optional - Default: null - BGP ASN (IP transit) - `is_multicast_over_transit_enabled` (boolean) - Optional - Default: false - Enable multicast (LISP transit) - `control_plane_network_device_ids` (list(string)) - Optional - Default: null - Control plane device IDs (LISP transit) ### Configuration Example ```hcl resource "catalystcenter_transit_network" "transit" { name = "Transit1" type = "IP_BASED_TRANSIT" routing_protocol_name = "BGP" autonomous_system_number = 65001 } ``` ``` -------------------------------- ### Use YAML directories in module Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Specifies directories from which to recursively load YAML configuration files. All .yml and .yaml files are discovered and merged. ```hcl module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" yaml_directories = ["./config", "./templates"] } ``` -------------------------------- ### catalystcenter_credentials_cli Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Creates CLI credentials for device access, including username, password, and optionally an enable password. ```APIDOC ## catalystcenter_credentials_cli ### Description Creates CLI credentials for device access. ### Parameters #### Path Parameters - `description` (string) - Required - Credential name/description - `username` (string) - Required - CLI username - `password` (string) - Required - CLI password (sensitive) - `enable_password` (string) - Optional - Enable/privileged password ### Request Example ```hcl resource "catalystcenter_credentials_cli" "admin" { description = "admin_cli" username = "admin" password = var.cli_password enable_password = var.enable_password } ``` ``` -------------------------------- ### Get Fabric L3 Virtual Network Data Source Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Looks up existing L3 Virtual Networks when global settings are not managed. It uses a for_each loop based on local variables. ```hcl data "catalystcenter_fabric_l3_virtual_network" "l3_vn" { for_each = var.manage_global_settings == false && length(var.managed_sites) != 0 ? try(local.global_l3_virtual_networks, {}) : {} virtual_network_name = each.key } ``` -------------------------------- ### Manage global settings in module Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Enables the management of global Catalyst Center settings, such as authentication templates and wireless profiles, in addition to specified sites. ```hcl # Manage Global credentials and templates module "catalystcenter" { manage_global_settings = true managed_sites = ["Global/Europe", "Global/Americas"] } ``` -------------------------------- ### catalystcenter_provision_devices (Bulk) Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Provisions multiple devices in a single bulk operation. This is efficient for onboarding many devices at once. ```APIDOC ## catalystcenter_provision_devices (Bulk) ### Description Provisions multiple devices in a single bulk operation. ### Resource Type `catalystcenter_provision_devices` ### Parameters #### Path Parameters - `site_id` (string) - Required - Target site ID - `devices` (map(object)) - Required - Device configurations #### devices Object Schema ```hcl { "10.1.1.1" = { role = string role_source = string } } ``` ### Configuration Example ```hcl resource "catalystcenter_provision_devices" "bulk" { site_id = catalystcenter_area.europe.id devices = { "10.1.1.1" = { role = "BORDER_ROUTER" role_source = "MANUAL" } "10.1.2.1" = { role = "EDGE_ROUTER" role_source = "MANUAL" } } } ``` ``` -------------------------------- ### Configure NTP Servers Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Use this resource to specify NTP servers for a given site. Ensure the site ID and a list of server IPs are provided. ```hcl resource "catalystcenter_ntp_settings" "ntp" { site_id = data.catalystcenter_site.global.id servers = ["8.8.8.8", "8.8.4.4"] } ``` ```yaml network_settings: network: - name: default_network ntp_servers: - 8.8.8.8 - 8.8.4.4 ``` -------------------------------- ### Use managed sites in module Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Specifies a subset of sites to manage. Site paths follow the format 'Global/Parent1/.../SiteName'. ```hcl module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" managed_sites = ["Global/Europe", "Global/Americas"] } ``` -------------------------------- ### Create a Catalyst Center Configuration Template Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Define a configuration template with content, language (JINJA/VELOCITY), and applicable device types. The project_id is required to associate the template with a project. ```hcl resource "catalystcenter_template" "snmp" { name = "SNMP Configuration" project_id = catalystcenter_project.devices.id description = "Standard SNMP settings" language = "JINJA" content = <<-EOT snmp-server community {{ snmp_community }} RO snmp-server host {{ snmp_server }} version 2c {{ snmp_community }} EOT } ``` -------------------------------- ### Apply with Bulk API Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/outputs-and-examples.md Apply the Terraform configuration with the deployment size set to 'large' to utilize the bulk API. ```bash terraform apply -var deployment_size=large ``` -------------------------------- ### Configure Device Discovery Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Sets up device discovery for specified IP ranges using a chosen protocol. The IP address list and discovery type are mandatory. ```hcl resource "catalystcenter_discovery" "discover" { ip_address_list = ["10.0.0.0/8", "172.16.0.0/12"] discovery_type = "SNMP" } ``` -------------------------------- ### catalystcenter_template Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Creates a configuration template. This resource defines the actual configuration content, language, and applicability to device types. ```APIDOC ## catalystcenter_template ### Description Creates a configuration template. ### Parameters #### Path Parameters - `name` (string) - Required - Template name - `project_id` (string) - Required - Project ID - `description` (string) - Optional - Template description - `language` (string) - Optional - Default: "JINJA" - Template language (JINJA/VELOCITY) - `content` (string) - Required - Template content - `device_types` (list(string)) - Optional - Applicable device types - `composite` (boolean) - Optional - Default: false - Is composite template ### Configuration Example ```hcl resource "catalystcenter_template" "snmp" { name = "SNMP Configuration" project_id = catalystcenter_project.devices.id description = "Standard SNMP settings" language = "JINJA" content = <<-EOT snmp-server community {{ snmp_community }} RO snmp-server host {{ snmp_server }} version 2c {{ snmp_community }} EOT } ``` ``` -------------------------------- ### Map Sites to Network Settings Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Creates a map that links each site path to its corresponding network settings configuration name. This is used to apply specific network configurations to different sites. ```hcl locals { sites_to_settings_map = merge( { "Global" = try(local.catalyst_center.sites.global.network_settings, null) }, { for area in try(local.catalyst_center.sites.areas, []) : try("${area.parent_name}/${area.name}", area.name) => try(area.network_settings, null) }, { for building in try(local.catalyst_center.sites.buildings, []) : "${building.parent_name}/${building.name}" => try(building.network_settings, null) }, { for floor in try(local.catalyst_center.sites.floors, []) : "${floor.parent_name}/${floor.name}" => try(floor.network_settings, null) } ) } ``` -------------------------------- ### Define managed sites variable Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Defines a list of site paths to be managed by the module. If empty, all sites are managed by default. ```hcl variable "managed_sites" { description = "List of sites to be managed. By default all sites will be managed." type = list(string) default = [] } ``` -------------------------------- ### Authentication Templates Configuration Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/data-model.md Defines authentication templates with settings for fallback timeouts, Wake-on-LAN, number of hosts, authentication order, and BPDU guard. Provides default values for most parameters. ```yaml authentication_templates: - name: string (required) dot1x_to_mab_fallback_timeout: integer (default: 21) wake_on_lan: boolean (default: false) number_of_hosts: string (default: "Unlimited") authentication_order: string (default: "dot1x") bpdu_guard: boolean (default: true) ``` -------------------------------- ### catalystcenter_ntp_settings Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Configures NTP servers for a specific site. Requires a site ID and a list of NTP server IP addresses. ```APIDOC ## catalystcenter_ntp_settings ### Description Configures NTP servers for a site. ### Parameters #### Path Parameters - `site_id` (string) - Required - Target site ID #### Query Parameters - `servers` (list(string)) - Required - List of NTP server IPs ### Request Example ```hcl resource "catalystcenter_ntp_settings" "ntp" { site_id = data.catalystcenter_site.global.id servers = ["8.8.8.8", "8.8.4.4"] } ``` ``` -------------------------------- ### Define YAML file list variable Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Defines a list of paths to YAML files for configuration. Files are loaded and merged in order. ```hcl variable "yaml_files" { description = "List of paths to YAML files." type = list(string) default = [] } ``` -------------------------------- ### Map Site Paths to Resource IDs (Bulk API) Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/locals-and-datasources.md Generates a map from site path strings to resource IDs when using bulk API operations. This is an alternative to `site_id_list` for bulk-created resources. ```hcl locals { site_id_list_bulk = merge( { for k, v in try(catalystcenter_areas.bulk_areas[0].areas, {}) : k => v.id }, { for k, v in try(catalystcenter_buildings.bulk_buildings[0].buildings, {}) : k => v.id }, { for k, v in try(catalystcenter_floors.bulk_floors[0].floors, {}) : k => v.id }, ) } ``` -------------------------------- ### Site Management Modes Configuration Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/architecture-and-patterns.md Configure site management using `managed_sites` and `manage_specific_sites_only` variables. This allows for managing all sites, specific sites and their children, or only specific sites. ```hcl managed_sites = [] manage_specific_sites_only = false # Result: All sites in YAML are managed local.sites = [ "Global/Europe", "Global/Europe/France", "Global/Americas", ... ] ``` ```hcl managed_sites = ["Global/Europe"] manage_specific_sites_only = false # Result: Europe and all children are managed local.sites = [ "Global/Europe", "Global/Europe/France", "Global/Europe/UK", ... ] ``` ```hcl managed_sites = ["Global/Europe/France"] manage_specific_sites_only = true # Result: Only France is managed local.sites = ["Global/Europe/France"] ``` -------------------------------- ### Enable Bulk API Operations Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/configuration.md Set this flag to true to utilize bulk API operations for faster configuration of areas, buildings, floors, and device provisioning. This is particularly beneficial for large site hierarchies. ```hcl variable "use_bulk_api" { description = "Flag indicating whether to use the bulk API for faster operations." type = bool default = false } ``` ```hcl module "catalystcenter" { use_bulk_api = true } ``` -------------------------------- ### Create SNMPv3 Credentials Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Use this resource to create SNMPv3 credentials with authentication and privacy settings. Ensure all required parameters like username, auth_password, and privacy_password are provided. ```hcl resource "catalystcenter_credentials_snmpv3" "snmpv3" { description = "snmpv3_user" username = "snmpuser" auth_type = "SHA" auth_password = var.snmp_auth_pass privacy_type = "AES128" privacy_password = var.snmp_privacy_pass } ``` -------------------------------- ### Create Wi-Fi 7 Profile Source: https://github.com/netascode/terraform-catalystcenter-nac-catalystcenter/blob/main/_autodocs/resource-reference.md Use this resource to create an 802.11be (Wi-Fi 7) profile with specified OFDMA and MU-MIMO settings. ```hcl resource "catalystcenter_dot11be_profile" "be_profile" { profile_name = "Wi-Fi7-Profile" ofdma_down_link = true ofdma_up_link = true mu_mimo_down_link = true } ```