Introduction
Network as Code allows for complete separation of data (defining variables) from logic (infrastructure declaration). With little to no knowledge about automation, users can configure Cisco UCS servers managed by Cisco Intersight in minutes, following the familiar Intersight structure of organizations, pools, policies, templates and profiles. This is achieved by separating the *.yaml files which contain the desired Intersight state from the Terraform Modules which map the definition of the desired state to Terraform resources. The data model and modules used in Network as Code are open-source and available as-is. For support and or customization it is required to engage with Cisco Professional Services.
The tree output below shows an example of a data model where the *.yaml files compose logical groups that map to constructs that Intersight users are very familiar with.
Directorydata
- organizations.nac.yaml
- pools.nac.yaml
- policies.nac.yaml
- templates.nac.yaml
- profiles.nac.yaml
- servers.nac.yaml
- main.tf
Intersight configuration can simply be managed via YAML files. Below is a simple example configuring an NTP policy in the built-in default organization, which is marked managed: false because it already exists in Intersight:
---compute: intersight: organizations: - name: default managed: false policies: ntp: - name: ntp enabled: true timezone: America/New_York ntp_servers: - ntp1.example.com - ntp2.example.comIntersight Provider
Section titled “Intersight Provider”The Terraform provider for Intersight (CiscoDevNet/intersight) manages configuration through the Intersight REST API. The same provider works with Intersight SaaS and with the Intersight Connected or Private Virtual Appliance.
The provider authenticates with an Intersight API key: a key ID and its secret key. The Intersight endpoint is set with the INTERSIGHT_ENDPOINT_URL environment variable, which is required since version 0.2.0 of the module.
Network as Code for Compute Module
Section titled “Network as Code for Compute Module”The Network as Code Terraform module for Compute is responsible for mapping the data to the corresponding Intersight resources. This module supports an inventory driven approach, where a complete Intersight configuration or parts of it are modeled in one or more YAML files.
The data model follows the Intersight building blocks. Organizations hold pools (IP, MAC, UUID, WWNN, WWPN and more), policies (BIOS, boot order, NTP, LAN connectivity and many others), templates (server, domain and chassis) and profiles. Each object references the others by name, and the module resolves the names to Intersight objects. Servers are defined in a top-level servers list, where each server gets a profile from a server profile template and can be pre-assigned by serial number.
For larger environments, the module can be split across several Terraform workspaces. The manage_* flags enable whole categories (pools, policies, templates, profiles, servers), and the managed_* lists narrow a workspace down to named or tagged organizations, profiles and servers.
Additional services
Section titled “Additional services”Cisco Customer Experience (CX) is able to help you with many additional services such as CI/CD integration, pre-change validation, integration with Information Technology Service Management (ITSM), as well as automated testing. Please reach out to your Cisco account team for more information.