### System Configuration Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Example of system-level configuration for an NX-OS device, including hostname, MTU, boot settings, and timezone. ```yaml system: hostname: string mtu: integer boot: nxos: string clock: timezone: string # Additional system properties... ``` -------------------------------- ### Feature Control Configuration Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Example of configuring feature enablement and feature sets for an NX-OS device. ```yaml feature: bfd: boolean bgp: boolean dhcp: boolean evpn: boolean hsrp: boolean isis: boolean lldp: boolean ntp: boolean ospf: boolean ospfv3: boolean pim: boolean ptp: boolean snmp: boolean ssh: boolean tacacs: boolean telemetry: boolean udld: boolean vpc: boolean # Additional feature controls... feature_set: fex: boolean mpls: boolean virtualization: boolean ``` -------------------------------- ### Example CLI Templates Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Provides examples of CLI templates for enabling gRPC and configuring route maps. The 'order' field controls execution sequence. ```yaml cli_templates: - name: enable_grpc order: 0 content: | configure terminal feature grpc exit - name: configure_policy order: 1 content: | configure terminal route-map CUSTOM permit 10 match ip address MY_ACL exit ``` -------------------------------- ### Environment-Specific Configuration Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Illustrates how to provide environment-specific configuration files (e.g., system settings) for different deployment stages. This allows for tailored configurations per environment. ```yaml nxos: devices: - name: prod-core-1 url: https://prod.site1.internal configuration: system: hostname: prod-core-1 mtu: 9216 ``` ```yaml nxos: devices: - name: staging-core-1 url: https://staging.site1.internal configuration: system: hostname: staging-core-1 mtu: 9216 ``` -------------------------------- ### VRF Configuration Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Example of defining Virtual Routing and Forwarding (VRF) configurations, including name, description, route distinguisher, and address families with route targets. ```yaml vrfs: - name: string description: string route_distinguisher: string # auto, IP:number, ASN:number formats address_families: - address_family: ipv4-unicast | ipv6-unicast route_target_imports: [string] route_target_exports: [string] route_target_both_auto: boolean ``` -------------------------------- ### Routing Configuration Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Illustrates the structure for configuring routing protocols such as BGP and OSPF/OSPFv3. Includes parameters for ASN, router ID, and network definitions. ```yaml routing: bgp: asn: integer router_id: string neighbors: [] vrfs: [] ospf: process_id: string networks: [] ospfv3: process_id: string ``` -------------------------------- ### Device-Specific Filtering Usage Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Demonstrates how to use the `test_devices` variable to apply changes to a single device or all devices. This is crucial for safe, incremental rollouts. ```bash # Test on single device first terraform apply -var 'test_devices=["TestSwitch"]' # Then apply to all terraform apply -var 'test_devices=[]' ``` -------------------------------- ### Enable BGP Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Example YAML snippet to enable BGP and configure its ASN and router ID. ```yaml configuration: feature: bgp: true routing: bgp: asn: 65000 router_id: 10.0.0.1 ``` -------------------------------- ### Configure Interface with IP Address Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Example YAML snippet to configure an Ethernet interface with an IP address, prefix length, and MTU. ```yaml configuration: interfaces: ethernets: - id: "1/1" ip_address: 10.0.0.1 ip_prefix_length: 30 mtu: 1500 ``` -------------------------------- ### Enable EVPN and VXLAN Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Example YAML snippet to enable EVPN and NV Overlay (VXLAN) features, and configure VRF settings including VNI and L3 VNI. ```yaml configuration: feature: evpn: true nv_overlay: true vrfs: - name: tenant1 vni: 100 l3vni: 1000 ``` -------------------------------- ### Multi-Site Deployment with Modules Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Example of organizing Terraform configuration for multi-site deployments using modules. Each module sources the NX-OS provider and specifies configuration directories. ```hcl module "site1" { source = "netascode/nac-nxos/nxos" yaml_directories = ["config/shared", "config/site1"] } module "site2" { source = "netascode/nac-nxos/nxos" yaml_directories = ["config/shared", "config/site2"] ``` -------------------------------- ### nxos_loopback_interface Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Example configuration for the nxos_loopback_interface resource, which manages loopback interfaces on NX-OS devices. It allows setting the interface name, description, and administrative state. ```hcl device = "DeviceName" interface = "lo1" | "lo100" | ... description = string enabled = true | false ``` -------------------------------- ### Interface Configuration Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Defines the structure for configuring various interface types including Ethernet, loopbacks, VLANs, and port channels. Each interface type has specific properties like ID, IP addressing, MTU, and description. ```yaml interfaces: ethernets: - id: string # e.g., "1/1", "1/2/1" ip_address: string ip_prefix_length: integer shutdown: boolean mtu: integer description: string # Additional interface properties... loopbacks: - id: string # e.g., "1", "100" # Similar properties to ethernet vlans: - id: string # e.g., "100", "200" name: string shutdown: boolean port_channels: - id: string # e.g., "1", "100" # Similar to ethernet interfaces management: [] # Management interface configuration ``` -------------------------------- ### NX-OS CLI Execution Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Execute custom CLI commands on NX-OS devices using the nxos_cli resource. Specify the device and the CLI command(s) to run. Resources execute sequentially based on their order. ```hcl resource "nxos_cli" "cli_0" { device = "DeviceName" cli = "show version" } ``` -------------------------------- ### CLI Template Processing Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Defines a device with custom CLI templates to be processed. The `order` field controls the execution sequence relative to Terraform resources and other CLI templates. ```yaml devices: - name: Switch1 cli_templates: - name: custom_config order: 0 content: | configure terminal feature grpc exit ``` -------------------------------- ### nxos_system Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Example configuration for the nxos_system resource, which manages system-level settings on NX-OS devices. This resource is created when various system configurations like hostname, MTU, boot settings, and clock configurations are present. ```hcl device = "DeviceName" admin_state = "enabled" | "disabled" hostname = string mtu = integer ethernet_mtu = integer boot = { nxos = "bootflash://..." | "disk1:/..." } clock = { timezone = "UTC" | "EST5EDT" | ... summer_time_recurring = { ... } } ``` -------------------------------- ### Create VRF Definition Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Example YAML snippet to create a Virtual Routing and Forwarding (VRF) instance with a specified name and route distinguisher. ```yaml configuration: vrfs: - name: customer1 route_distinguisher: "65000:100" ``` -------------------------------- ### Local Sensitive File Write Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Write rendered device configuration to a YAML file for debugging. This resource depends on the 'write_model_file' input variable and uses a utility to encode the configuration model. ```hcl resource "local_sensitive_file" "model" { filename = var.write_model_file content = provider::utils::yaml_encode(local.rendered.raw) } ``` -------------------------------- ### Configuration Merging Example Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Illustrates how multiple YAML files and the native Terraform model are merged, with later values overriding earlier ones. Arrays are replaced, not merged. ```yaml # defaults/defaults.yaml defaults: nxos: devices: true # config1.yaml nxos: devices: - name: Switch1 configuration: system: hostname: Switch1 # config2.yaml (merged after config1.yaml) nxos: devices: - name: Switch1 configuration: system: mtu: 9216 # Adds to existing config1 system block ``` -------------------------------- ### nxos_physical_interface Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Example configuration for the nxos_physical_interface resource, used to manage physical, port-channel, and management interfaces on NX-OS devices. It supports attributes like speed, duplex, MTU, and description. ```hcl device = "DeviceName" interface = "eth1/1" | "po1" | "mgmt0" speed = "1Gbps" | "10Gbps" | "40Gbps" | ... duplex = "auto" | "full" enabled = true | false description = string mtu = integer medium = "copper" | "fiber" auto_negotiate = true | false fec_mode = "cl91" | "cl74" | ... ``` -------------------------------- ### nxos_svi_interface Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Example configuration for the nxos_svi_interface resource, used to manage Switched Virtual Interfaces (SVIs) or VLAN interfaces on NX-OS devices. It supports VRF association, description, and state control. ```hcl device = "DeviceName" interface = "vlan100" | "vlan200" | ... vrf = "default" | "VrfName" description = string enabled = true | false autostate = true | false proxy_arp = true | false proxy_arp_ignore = true | false ``` -------------------------------- ### Apply Complex ACLs with CLI Templates Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Define and apply complex Access Control Lists (ACLs) using CLI templates. This example shows a common pattern for managing network access. ```yaml nxos: devices: - name: Edge1 cli_templates: - name: complex_acl order: 2 content: | configure terminal ip access-list extended MANAGEMENT 10 permit tcp 10.0.0.0 0.0.255.255 any eq 22 20 permit tcp 10.0.0.0 0.0.255.255 any eq 443 30 deny ip any any log exit ``` -------------------------------- ### nxos_feature Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Example configuration for the nxos_feature resource, used to enable or disable features and feature sets on NX-OS devices. It is created when feature or feature_set blocks are defined in the configuration. ```hcl device = "DeviceName" analytics = "enabled" | "disabled" bfd = "enabled" | "disabled" bgp = "enabled" | "disabled" dhcp = "enabled" | "disabled" evpn = "enabled" | "disabled" hsrp = "enabled" | "disabled" isis = "enabled" | "disabled" lacp = "enabled" | "disabled" lldp = "enabled" | "disabled" nv_overlay = "enabled" | "disabled" ospf = "enabled" | "disabled" ospfv3 = "enabled" | "disabled" pim = "enabled" | "disabled" ptp = "enabled" | "disabled" snmp = "enabled" | "disabled" ssh = "enabled" | "disabled" udld = "enabled" | "disabled" vpc = "enabled" | "disabled" # ... additional features feature_sets = { fex = { admin_state = "enabled" | "disabled" } mpls = { admin_state = "enabled" | "disabled" } virtualization = { admin_state = "enabled" | "disabled" } } ``` -------------------------------- ### Terraform Initialization and Application Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/examples/system/README.md Initialize, plan, and apply Terraform configurations. Remember to destroy resources when finished. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Basic YAML-Driven Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/module-reference.md Demonstrates basic module usage by loading device configuration from a YAML file. Ensure the YAML file is correctly structured and accessible. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_files = ["configs/system.nac.yaml"] } ``` ```yaml nxos: devices: - name: Switch1 url: https://192.0.2.1 configuration: system: hostname: Switch1 mtu: 9216 ``` -------------------------------- ### Terraform Module Installation Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Add the nxos-nac-nxos module to your Terraform configuration. Ensure you specify a version constraint. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_files = ["nxos-config.yaml"] } ``` -------------------------------- ### Advanced Multi-File Configuration with Filtering Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/module-reference.md Demonstrates loading configurations from multiple YAML directories and template files, managing specific devices, and saving the rendered configuration. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_directories = ["configs/shared", "configs/site1"] template_files = ["templates/banner.txt"] managed_devices = ["Switch1", "Switch2"] save_config = true write_model_file = "rendered_model.yaml" } ``` -------------------------------- ### Multi-Site Deployment Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/module-reference.md Illustrates how to deploy configurations to multiple sites by defining separate module blocks for each site, referencing shared and site-specific configurations. ```hcl module "nxos_site1" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_directories = ["configs/shared", "configs/site1"] managed_devices = var.site1_devices } module "nxos_site2" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_directories = ["configs/shared", "configs/site2"] managed_devices = var.site2_devices } ``` -------------------------------- ### Conditional Resource Creation for nxos_system Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Demonstrates conditional resource creation for the 'nxos_system' resource. It iterates over devices and creates the resource only if specific configuration blocks (hostname, mtu, ethernet) are present. ```hcl resource "nxos_system" "system" { for_each = { for device in local.devices : device.name => device if try(local.device_config[device.name].system.hostname, null) != null || try(local.device_config[device.name].system.mtu, null) != null || try(local.device_config[device.name].system.ethernet, null) != null || # ... more conditions } } ``` -------------------------------- ### Enable Additional Features with CLI Templates Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Use CLI templates to enable specific features like gRPC and Netconf on NX-OS devices. Ensure features are enabled in the correct order. ```yaml nxos: devices: - name: Switch1 cli_templates: - name: enable_grpc order: 0 content: | configure terminal feature grpc grpc port 50051 exit - name: enable_netconf order: 1 content: | configure terminal feature netconf exit ``` -------------------------------- ### Interactive Query with Terraform Console Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Demonstrates how to use `terraform console` to interactively query local variables like device lists and configurations. This is helpful for debugging and exploration. ```bash terraform console > local.devices > local.device_config["Switch1"] > local.lldp_interfaces_by_device["Switch1"] ``` -------------------------------- ### System Configuration Schema Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Details the schema for system-level configurations, including hostname, MTU, boot image, clock settings, and network-related parameters. ```yaml system: hostname: string # Device hostname mtu: integer # System MTU (1500-9216) ethernet: mtu: integer # Ethernet interface default MTU boot: nxos: string # Boot image path clock: timezone: string # e.g., "UTC", "EST5EDT" summer_time_recurring: start_day_of_week: string # e.g., "first-sunday" start_month: string # e.g., "march" end_day_of_week: string end_month: string interface_breakout_modules: # Breakout port configurations - slot: integer port: integer breakout_type: string cli_aliases: # Command aliases - name: string command: string copp_profile: string # CoPP policy name copp_rate_limit: boolean icam_monitor_interval: integer icam_monitor_history: integer icam_monitor_scale: string smart_licensing_transport: string # "callhome", "cslu", "smart", "off" smart_licensing_url_cslu: string line_console_exec_timeout: integer line_vty_exec_timeout: integer line_vty_session_limit: integer vdcs: - id: integer name: string nxapi: enabled: boolean certificate: key: string cert: string cfs_distribute: boolean # Distribute configuration cfs_eth_distribute: boolean cfs_ipv4_distribute: boolean cfs_ipv4_mcast_address: string cfs_ipv6_distribute: boolean cfs_ipv6_mcast_address: string ``` -------------------------------- ### Terraform Planning and Applying Workflow Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md A standard Terraform workflow for initializing, planning, reviewing, and applying configuration changes. Includes steps for verifying the rendered model and applying the plan. ```bash # Initialize Terraform terraform init # Plan changes terraform plan -out=tfplan # Review the plan and rendered model cat model-output.yaml # Apply if satisfied terraform apply tfplan # Verify configuration on devices ssh admin@192.0.2.1 show running-config ``` -------------------------------- ### Site-Specific Modules with `for_each` Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Dynamically create multiple instances of the nxos module for different environments using `for_each`. This pattern is useful for managing multi-site or multi-environment deployments. ```hcl variable "environments" { type = list(string) default = ["prod", "staging", "dev"] } module "nxos_site" { for_each = toset(var.environments) source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_directories = ["config/shared", "config/${each.value}"] save_config = each.value == "prod" ? true : false } ``` -------------------------------- ### Load YAML and Template Files Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Loads YAML configuration files from specified directories and files, and template files from directories and files. This is the first phase of configuration processing. ```hcl locals { yaml_strings = concat( flatten([ for dir in var.yaml_directories : [ for file in fileset(".", "${dir}/**/*.{yml,yaml}") : file(file) ] ]), [for file in var.yaml_files : file(file)] ) defaults_yaml = file("${path.module}/defaults/defaults.yaml") file_templates = merge( merge([for dir in var.template_directories : { for f in fileset(".", "${dir}/**/*") : f => file(f) }]...), { for f in var.template_files : f => file(f) } ) } ``` -------------------------------- ### Module Defaults Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/configuration.md Shows the default settings applied by the module, including template order and device management status. Devices are managed by default unless explicitly overridden. ```yaml defaults: nxos: templates: order: 0 devices: managed: true ``` -------------------------------- ### NX-OS System Configuration in YAML Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/examples/system/README.md Define system-level configurations such as hostname and MTU for an NX-OS device using YAML. ```yaml nxos: devices: - name: Switch1 url: https://1.2.3.4 configuration: system: hostname: Switch1 mtu: 9216 ``` -------------------------------- ### nxos_logging.logging Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device logging settings. This resource is created when the `logging` configuration block is present. ```APIDOC ## nxos_logging.logging ### Description Configures Per-device logging configuration. ### Configuration Path `configuration.logging` ### Key Attributes - **device** (string) - DeviceName ``` -------------------------------- ### Configuration Validation with Model Export Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/module-reference.md Demonstrates how to export the rendered configuration model to a file for review and validation using `terraform plan` before applying changes. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_files = ["config.nac.yaml"] write_model_file = "model.yaml" # Export for review } ``` -------------------------------- ### nxos_queuing_qos Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device queuing QoS settings. Requires the 'queuing_qos' configuration block to be present. ```hcl configuration.queuing_qos ``` -------------------------------- ### Export Rendered Model for Review Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Configure the module to write the fully rendered configuration model to a file for review before applying changes. This aids in validation. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_files = ["device.yaml"] write_model_file = "${path.module}/model-output.yaml" } ``` -------------------------------- ### Native Terraform Configuration with Device Model Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/module-reference.md Shows how to define device configurations directly within Terraform using a structured model, including system and feature settings. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" model = { nxos = { devices = [ { name = "Switch1" url = "https://192.0.2.1" configuration = { system = { hostname = "Switch1" mtu = 9216 } feature = { bgp = true ospf = true } } } ] } } } ``` -------------------------------- ### nxos_default_qos Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device default QoS settings. Requires the 'default_qos' configuration block to be present. ```hcl configuration.default_qos ``` -------------------------------- ### nxos_queuing_qos.queuing_qos Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device queuing QoS (Quality of Service) settings. This resource is created when the `queuing_qos` configuration block is present. ```APIDOC ## nxos_queuing_qos.queuing_qos ### Description Configures Per-device queuing QoS settings. ### Configuration Path `configuration.queuing_qos` ``` -------------------------------- ### Basic Single-Device Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Configure a single NX-OS device using a YAML file. Ensure the CiscoDevNet/nxos provider and the netascode/nac-nxos/nxos module are defined. ```hcl terraform { required_providers { nxos = { source = "CiscoDevNet/nxos" version = "~> 0.13.1" } } } module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_files = ["device.nac.yaml"] } ``` ```yaml nxos: devices: - name: Switch1 url: https://192.0.2.1 configuration: system: hostname: Switch1 mtu: 9216 feature: bgp: true ospf: true ``` -------------------------------- ### nxos_ptp.ptp Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device PTP (Precision Time Protocol) settings. This resource is created when the `ptp` configuration block is present. ```APIDOC ## nxos_ptp.ptp ### Description Configures Per-device PTP configuration. ### Configuration Path `configuration.ptp` ### Key Attributes - **device** (string) - DeviceName - **mode** (string) - "boundary" | "transparent" | ... - **announce_interval** (integer) - **sync_interval** (integer) - **delay_req_interval** (integer) ``` -------------------------------- ### nxos_ptp Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device PTP settings. Requires the 'ptp' configuration block to be present. ```hcl device = "DeviceName" mode = "boundary" | "transparent" | ... announce_interval = integer sync_interval = integer delay_req_interval = integer ``` -------------------------------- ### Multi-File Configuration Organization Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Organize network configuration into multiple YAML files across different directories for better maintainability. Includes shared configurations and site-specific templates. ```hcl module "nxos" { source = "netascode/nac-nxos/nxos" version = ">= 0.1.0" yaml_directories = ["config/shared", "config/site1"] template_files = ["templates/banner.txt", "templates/motd.txt"] managed_devices = var.site_devices save_config = true } ``` ```yaml nxos: devices: - name: Switch1 url: https://10.1.1.1 - name: Switch2 url: https://10.1.2.1 ``` ```yaml nxos: devices: - name: Switch1 configuration: feature: bgp: true ospf: true - name: Switch2 configuration: feature: evpn: true nv_overlay: true ``` ```yaml nxos: devices: - name: Switch1 configuration: system: hostname: site1-core-1 mtu: 9216 - name: Switch2 configuration: system: hostname: site1-core-2 mtu: 9216 ``` -------------------------------- ### Sequential NX-OS CLI Template Execution Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Executes NX-OS CLI templates sequentially, ensuring that `cli_0` completes before `cli_1` begins. This is useful for ordered configuration application. ```hcl resource "nxos_cli" "cli_1" { depends_on = [nxos_cli.cli_0] } ``` -------------------------------- ### Configuration Block Schema Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Outlines the structure for the 'configuration' object, which contains detailed device-specific settings such as system, features, interfaces, and routing. ```yaml configuration: system: {} feature: {} feature_set: {} # Feature sets (mpls, fex, virtualization) vrfs: [] # VRF configurations interfaces: {} # Interface definitions routing: {} # Routing protocols bridge_domains: [] # Bridge domains access_lists: [] # Access control lists route_policies: [] # Routing policies dhcp: {} # DHCP configuration dns: {} # DNS configuration snmp: {} # SNMP configuration ntp: {} # NTP configuration logging: {} # Logging configuration hsrp: {} # HSRP configuration vpc: {} # VPC configuration evpn: {} # EVPN configuration nvo: {} # NVO overlay # ... additional feature blocks ``` -------------------------------- ### Render Device Configurations Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Merges and renders device configurations using the netascode/utils provider. It takes loaded YAML content, model, defaults, templates, and device lists as input. ```hcl locals { rendered = provider::utils::render_device_configs( local.yaml_strings, var.model, local.defaults_yaml, local.file_templates, var.managed_devices, var.managed_device_groups ) } ``` -------------------------------- ### Configure OSPFv3 Process Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Sets up an OSPFv3 routing process, specifying the process ID, administrative state, and router ID. ```hcl resource "nxos_ospfv3" "ospfv3" { device = "DeviceName" process_id = "1" admin_state = "enabled" router_id = "2001:db8::1" } ``` -------------------------------- ### nxos_bfd Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device BFD settings. Requires the 'bfd' configuration block to be present. ```hcl device = "DeviceName" enabled = true | false slow_timer = integer ipv4_session_echo_rx_interval = integer ``` -------------------------------- ### Minimal NX-OS Device Configuration (YAML) Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Defines a minimal configuration for a single NX-OS device, including its name, management URL, and hostname. ```yaml nxos: devices: - name: Switch1 url: https://192.0.2.1 configuration: system: hostname: Switch1 ``` -------------------------------- ### Test Configuration on Subset of Devices Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Commands to test Terraform configuration on a subset of managed devices before a full deployment. An empty list deploys all devices. ```bash terraform apply -var 'managed_devices=["test-switch"]' terraform apply -var 'managed_devices=[]' # Full deployment ``` -------------------------------- ### nxos_ntp Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device NTP settings. Requires the 'ntp' configuration block to be present. ```hcl device = "DeviceName" ``` -------------------------------- ### nxos_vpc Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device VPC settings. Requires the 'vpc' configuration block to be present. ```hcl device = "DeviceName" domain_id = integer peer_keepalive = { dest = "a.b.c.d" source = "a.b.c.d" vrf = "management" } ``` -------------------------------- ### Export Rendered Model for Review Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Command to export the fully merged and processed configuration model to a YAML file for review before applying changes. ```bash terraform apply -var 'write_model_file=model.yaml' cat model.yaml # Review merged config ``` -------------------------------- ### System Configuration Maps Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md These locals define mappings from configuration values to their corresponding NX-OS API formats for various features like link status, licensing, and CDP. ```hcl locals { log_event_map = { "link-status-default" = "linkStatusDefault" "link-status-enable" = "linkStatusEnable" "none" = "none" "trunk-status-default" = "trunkStatusDefault" "trunk-status-enable" = "trunkStatusEnable" } layer_map = { "layer2" = "Layer2" "layer3" = "Layer3" } smart_licensing_transport_map = { "callhome" = "transportCallhome" "cslu" = "transportCslu" "off" = "transportOff" "smart" = "transportSmart" } cdp_format_device_id_map = { "none" = "none" "mac" = "mac" "serial-number" = "serialNum" "system-name" = "sysName" } } ``` -------------------------------- ### nxos_network_qos Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device network QoS settings. Requires the 'network_qos' configuration block to be present. ```hcl configuration.network_qos ``` -------------------------------- ### Validate Configuration Before Apply Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md A sequence of Terraform commands to plan, review the rendered model, and then apply the configuration. This workflow ensures changes are validated before deployment. ```bash # Generate plan and review rendered model terraform plan -out=tfplan # Check the exported model cat model-output.yaml # Apply only if satisfied terraform apply tfplan ``` -------------------------------- ### nxos_default_qos.default_qos Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device default QoS (Quality of Service) settings. This resource is created when the `default_qos` configuration block is present. ```APIDOC ## nxos_default_qos.default_qos ### Description Configures Per-device default QoS settings. ### Configuration Path `configuration.default_qos` ``` -------------------------------- ### Updating Configuration with Terraform Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Demonstrates the process of updating configuration by modifying YAML files and then applying the changes using Terraform. This involves planning and applying the updated configuration. ```yaml # device.yaml: increase MTU nxos: devices: - name: Switch1 configuration: system: mtu: 9216 # Changed from 1500 ``` ```bash terraform plan terraform apply ``` -------------------------------- ### nxos_access_list Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-ACL across devices. Requires entries in the 'access_lists' array. ```hcl device = "DeviceName" name = string type = "ipv4" | "ipv6" ``` -------------------------------- ### nxos_telemetry Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device telemetry settings. Requires the 'telemetry' configuration block to be present. ```hcl configuration.telemetry ``` -------------------------------- ### Apply Single Device Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/README.md Command to apply Terraform configuration for a single device using a specified YAML file. ```bash terraform apply -var yaml_files='["switch1.yaml"]' ``` -------------------------------- ### nxos_netflow Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device NetFlow settings. Requires the 'netflow' configuration block to be present. ```hcl configuration.netflow ``` -------------------------------- ### NX-OS CLI Resource with Dependencies Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Defines an NX-OS CLI resource that depends on all standard feature resources. This ensures standard resources are applied before CLI commands. ```hcl resource "nxos_cli" "cli_0" { depends_on = [ nxos_access_list.access_list, nxos_analytics.analytics, nxos_bfd.bfd, # ... all other feature resources ] } ``` -------------------------------- ### nxos_hsrp Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device HSRP settings. Requires the 'hsrp' configuration block to be present. ```hcl device = "DeviceName" version = 1 | 2 ``` -------------------------------- ### nxos_snmp Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-device SNMP settings. Requires the 'snmp' configuration block to be present. ```hcl device = "DeviceName" contact = string location = string ``` -------------------------------- ### nxos_route_policy Resource Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configure Per-route-policy across devices. Requires entries in the 'route_policies' array. ```hcl device = "DeviceName" name = string ``` -------------------------------- ### nxos_bfd.bfd Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device BFD (Bidirectional Forwarding Detection) settings. This resource is created when the `bfd` configuration block is present. ```APIDOC ## nxos_bfd.bfd ### Description Configures Per-device BFD configuration. ### Configuration Path `configuration.bfd` ### Key Attributes - **device** (string) - DeviceName - **enabled** (boolean) - true | false - **slow_timer** (integer) - **ipv4_session_echo_rx_interval** (integer) ``` -------------------------------- ### Output Resolved NX-OS Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Outputs the full resolved NX-OS configuration. Use this to inspect the final configuration generated by the templates. ```hcl output "rendered_nxos" { value = local.rendered.resolved.nxos description = "Full resolved NX-OS configuration" } ``` -------------------------------- ### Output Per-Device Configuration Map Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Outputs a map of configurations, keyed by device name. This helps in verifying the specific configuration applied to each device. ```hcl output "device_config" { value = local.device_config description = "Per-device configuration" } ``` -------------------------------- ### NVO (VXLAN) Configuration Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/usage-patterns.md Configures Network Virtualization Overlay (NVO) settings for VXLAN. This includes defining loopback interfaces and the VTEP source interface. ```yaml nxos: devices: - name: Leaf1 configuration: interfaces: loopbacks: - id: "1" ip_address: 10.0.0.11 ip_prefix_length: 32 nvo: source_interface: lo1 vtep_ip: 10.0.0.11 ``` -------------------------------- ### nxos_netflow.netflow Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device NetFlow settings. This resource is created when the `netflow` configuration block is present. ```APIDOC ## nxos_netflow.netflow ### Description Configures Per-device NetFlow configuration. ### Configuration Path `configuration.netflow` ``` -------------------------------- ### Configure BGP Process Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Sets up a BGP routing process with ASN, administrative state, and router ID. Supports VRF and address family configurations. ```hcl resource "nxos_bgp" "bgp" { device = "DeviceName" asn = 65001 admin_state = "enabled" router_id = "192.168.1.1" vrfs = { "default" = { router_id = "192.168.1.1" } } address_families = { "ipv4-ucast" = {} } neighbors = [ { "remote-as" = 65002 "remote-ip" = "10.0.0.2" } ] } ``` -------------------------------- ### nxos_vpc.vpc Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device VPC (Virtual Port Channel) settings. This resource is created when the `vpc` configuration block is present. ```APIDOC ## nxos_vpc.vpc ### Description Configures Per-device VPC configuration. ### Configuration Path `configuration.vpc` ### Key Attributes - **device** (string) - DeviceName - **domain_id** (integer) - **peer_keepalive** (object) - **dest** (string) - a.b.c.d - **source** (string) - a.b.c.d - **vrf** (string) - management ``` -------------------------------- ### nxos_ntp.ntp Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-device NTP (Network Time Protocol) settings. This resource is created when the `ntp` configuration block is present. ```APIDOC ## nxos_ntp.ntp ### Description Configures Per-device NTP configuration. ### Configuration Path `configuration.ntp` ### Key Attributes - **device** (string) - DeviceName ``` -------------------------------- ### Write Rendered Model to File Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Creates a sensitive local file containing the YAML representation of the fully rendered configuration model. This is useful for debugging, validation, and archiving. ```hcl resource "local_sensitive_file" "model" { count = var.write_model_file != "" ? 1 : 0 content = provider::utils::yaml_encode(local.rendered.raw) filename = var.write_model_file } ``` -------------------------------- ### Output List of Managed Devices Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/internals.md Outputs the list of devices managed by the configuration. This is useful for verifying which devices are included in the deployment. ```hcl output "devices" { value = local.devices description = "List of managed devices" } ``` -------------------------------- ### Loopback Interface Configuration Schema Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Schema for configuring loopback interfaces. Supports IP addressing and VRF assignment. ```yaml loopbacks: - id: string # Loopback ID (e.g., "1", "100") description: string vrf: string ip_address: string ip_prefix_length: integer ipv6_address: string ipv6_prefix_length: integer enabled: boolean nd: {} # IPv6 neighbor discovery ``` -------------------------------- ### nxos_route_policy.route_policy Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures Per-route-policy across devices. This resource is created when the `route_policies` array has entries. ```APIDOC ## nxos_route_policy.route_policy ### Description Configures Per-route-policy across devices. ### Configuration Path `configuration.route_policies[]` ### Key Attributes - **device** (string) - DeviceName - **name** (string) ``` -------------------------------- ### Configure ISIS Process Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Configures an ISIS routing process with an instance tag, administrative state, and network entity title. ```hcl resource "nxos_isis" "isis" { device = "DeviceName" instance_tag = "1" admin_state = "enabled" net = "49.0001.1111.1111.1111.00" } ``` -------------------------------- ### Device Object Schema Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Specifies the structure for individual device configurations within the 'nxos.devices' array, including essential connection details and optional settings. ```yaml nxos: devices: - name: string # Unique device identifier (required) url: string # NX-OS NETCONF/CLI URL (required) group: string # Optional group membership managed: boolean # Override management status (optional) configuration: {} # Device configuration block (optional) cli_templates: [] # CLI templates (optional) ``` -------------------------------- ### Root Schema Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/yaml-schema.md Defines the top-level structure for NX-OS device configurations, including arrays for devices and optional device groups. ```yaml nxos: devices: [] # Array of device configurations device_groups: [] # Optional: groupings for organizational purposes ``` -------------------------------- ### Configure Bridge Domain Source: https://github.com/netascode/terraform-nxos-nac-nxos/blob/main/_autodocs/resources.md Creates a bridge domain with a unique VNI and description. ```hcl resource "nxos_bridge_domain" "bridge_domain" { device = "DeviceName" vni = 10001 description = "Bridge domain for tenant network" } ```