Scaling
As you start adding more resources to your configuration a few problems can arise:
- The Terraform state file becomes bigger and making changes with Terraform takes much longer.
- A single shared statefile is a risk. Making a change in a Development tenant could have implications to a Production tenant.
- No ability to run changes in parallel. Only one concurrent plan may run at any given time as the statefile is locked during the operation.
These problems are not unique to Network as Code and would occur when scaling any Terraform resources using a single state file. To address these problems users have to consider distributing state. For more information about Terraform state see: https://developer.hashicorp.com/terraform/language/state.
In Catalyst Center environments, this becomes particularly relevant when managing large deployments with multiple sites, fabric sites, device provisioning, IP pools, network profiles, wireless configurations, and templates. The Catalyst Center Terraform module supports managing different site configurations independently, allowing you to separate your infrastructure management by geographical locations, organizational boundaries, or functional areas.
Why Use Multistate Configuration for Catalyst Center?
Section titled “Why Use Multistate Configuration for Catalyst Center?”When managing large Catalyst Center deployments across multiple sites, using a single Terraform state file can become problematic. As your deployment grows, several challenges arise:
- Performance: Large state files with hundreds of sites, devices, and configurations slow down Terraform operations significantly
- Risk Management: Changes to one site’s configuration could inadvertently affect other sites or global settings
- Parallel Operations: Only one Terraform operation can run at a time with a shared state, limiting deployment velocity
- Team Collaboration: Different teams managing different sites (e.g., regional teams) need isolation and independent deployment capabilities
- Blast Radius: Configuration errors or failed deployments affect the entire infrastructure rather than isolated components
Multistate configuration addresses these issues by separating the Terraform state while maintaining a shared data model for consistency across your Catalyst Center deployment.
Architecture Overview
Section titled “Architecture Overview”The multistate approach separates your infrastructure into logical boundaries:
- COMMON: Manages global settings, templates, and parent sites
- Site-specific folders: Each site (Krakow, Warsaw, etc.) manages its own resources
- Shared data model: All instances use the same YAML configuration files
Folder Structure
Section titled “Folder Structure”Here’s the recommended folder structure for a multistate Catalyst Center deployment:
Directorydata/
- area.yaml
- network_profiles.yaml
- network_settings.yaml
- sites.yaml
- wireless.yaml
Directorytemplates/
- template1.j2
- template2.j2
- templates.yaml
DirectoryCOMMON/
- main.tf
- terraform.tfstate
DirectoryKrakow/
- main.tf
- terraform.tfstate
DirectoryWarsaw/
- main.tf
- terraform.tfstate
Configuration Flags
Section titled “Configuration Flags”The Catalyst Center Terraform module provides several flags to control what resources each instance manages:
manage_global_settings
Section titled “manage_global_settings”- Type: Boolean (default: true)
- Purpose: Controls whether this instance manages global configuration items
- Rule: Only one Terraform instance should have this set to
true
- Manages: Templates, global settings, global IP pools, L3 VNs
managed_sites
Section titled “managed_sites”- Type: List of strings
- Purpose: Specifies which sites this instance should manage
- Format: Site hierarchy path (e.g.,
["Global/Poland/Krakow"]
and by default, it will also include all child sites)
manage_specific_sites_only
Section titled “manage_specific_sites_only”- Type: Boolean (default: false)
- Purpose: When
true
, only manages the specified sites, not their children - Use case: Prevents managing child sites when you only want to manage specific sites
Configuration Flags Reference
Section titled “Configuration Flags Reference”Name | Description | Type | Default |
---|---|---|---|
manage_global_settings | Flag to indicate if global settings should be managed. | bool | true |
manage_specific_sites_only | If true, manage only the specified site listed in managed_sites. If false, also manage all child sites under each managed site. | bool | false |
managed_sites | List of sites to be managed. By default all sites will be managed. | list(string) | [] |
Site Hierarchy Example
Section titled “Site Hierarchy Example”Consider this site hierarchy:
Global└── Poland ├── Krakow │ ├── Building_A │ └── Building_B └── Warsaw ├── Office_1 └── Office_2
Configuration Examples
Section titled “Configuration Examples”COMMON Folder Configuration
Section titled “COMMON Folder Configuration”The COMMON folder manages global settings and the parent Poland site:
module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "0.2.0"
yaml_directories = ["../data/"] templates_directories = ["../data/templates/"]
manage_global_settings = true managed_sites = ["Global/Poland"] manage_specific_sites_only = true}
Key points for COMMON configuration:
manage_global_settings = true
: This instance manages global resourcesmanaged_sites = ["Global/Poland"]
: Specify global parent sitemanage_specific_sites_only = true
: Prevents managing Krakow and Warsaw (they’re managed separately)
Krakow Configuration
Section titled “Krakow Configuration”module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "0.2.0"
yaml_directories = ["../data/"] templates_directories = ["../data/templates/"]
manage_global_settings = false managed_sites = ["Global/Poland/Krakow"]}
Key points for Krakow configuration:
manage_global_settings = false
: This instance doesn’t manage global resourcesmanaged_sites = ["Global/Poland/Krakow"]
: Manages only the Krakow sitemanage_specific_sites_only
defaults tofalse
: Automatically manages child sites (Building_A, Building_B)
Warsaw Configuration
Section titled “Warsaw Configuration”module "catalystcenter" { source = "netascode/nac-catalystcenter/catalystcenter" version = "0.2.0"
yaml_directories = ["../data/"] templates_directories = ["../data/templates/"]
manage_global_settings = false managed_sites = ["Global/Poland/Warsaw"]}
Data Model Configuration
Section titled “Data Model Configuration”All Terraform instances share the same data model. Here’s an example of the site hierarchy definition:
---catalyst_center: sites: areas: - name: Poland parent_name: Global - name: Krakow parent_name: Global/Poland - name: Warsaw parent_name: Global/Poland - name: Building_A parent_name: Global/Poland/Krakow - name: Building_B parent_name: Global/Poland/Krakow - name: Office_1 parent_name: Global/Poland/Warsaw - name: Office_2 parent_name: Global/Poland/Warsaw
Deployment Workflow
Section titled “Deployment Workflow”1. Deploy Global Resources First
Section titled “1. Deploy Global Resources First”cd COMMONterraform initterraform planterraform apply
This creates:
- Global settings and templates
- The Poland parent site
- L3 VNs and other global resources
2. Deploy Site-Specific Resources
Section titled “2. Deploy Site-Specific Resources”# Deploy Krakow sitecd ../Krakowterraform initterraform planterraform apply
# Deploy Warsaw site (can be done in parallel)cd ../Warsawterraform initterraform planterraform apply
Best Practices
Section titled “Best Practices”1. Execution Order
Section titled “1. Execution Order”- Always deploy Global resources first (main.tf file in COMMON folder)
- Site-specific deployments can run in parallel after COMMON is complete
2. State Management
Section titled “2. State Management”- Each folder maintains its own Terraform state
- Use remote state backends for team collaboration
- Consider state locking mechanisms
3. Data Model Consistency
Section titled “3. Data Model Consistency”- Keep all YAML files in a shared
data/
directory - Use version control to ensure consistency across all instances
- Test changes in a development environment first
4. Site Hierarchy Planning
Section titled “4. Site Hierarchy Planning”- Plan your site hierarchy before implementation
- Consider future expansion when designing the structure
- Document the hierarchy for team reference
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Issue: Child sites are being managed by the wrong instance Solution: Check manage_specific_sites_only
flag in parent site configurations
Issue: Global resources are being managed by multiple instances Solution: Ensure only one instance has manage_global_settings = true
(typically in COMMON folder)
Issue: Sites not being created Solution: Verify the site hierarchy in your YAML files matches the managed_sites
configuration
Validation Commands
Section titled “Validation Commands”# Check what resources each instance will manageterraform plan
# Verify site hierarchyterraform show | grep -A 5 "catalystcenter_area"
# Check for state conflictsterraform state list
Advanced Scenarios
Section titled “Advanced Scenarios”Managing Multiple Regions
Section titled “Managing Multiple Regions”For multi-region deployments, extend the pattern:
Directorydata/
- …
DirectoryCOMMON/
- …
DirectoryREGION_EMEA/
DirectoryKrakow/
- …
DirectoryWarsaw/
- …
DirectoryREGION_APAC/
DirectorySingapore/
- …
DirectoryTokyo/
- …
Selective Child Site Management
Section titled “Selective Child Site Management”If you need to manage only specific child sites:
module "catalystcenter" { source = "..."
manage_global_settings = false managed_sites = [ "Global/Poland/Krakow/Building_A", "Global/Poland/Krakow/Building_B" ] manage_specific_sites_only = true}