Automating UCS Server Provisioning with Terraform and Intersight

This repository pairs with the Cisco Live 2021 Anytime Breakout Session BRKDEV-2004 session.
The guiding principle for this example repository is to provide a working, usable set of
Terraform configuration files. While some best practices may suggest a more frequent use of
variables throughout the plan, (a) that approach would reduce the educational value and
(b) many of these "hard coded" values derive from existing best practice parameters within
the UCS ecosystem. Of course, they should be adjusted based on your application needs but
(with any luck) most will not need to be changed.

There are some organization specific variables that were built into this Terraform configuration.
Those variables and their defaults are defined in the variables.tf file of each subdirectory.
You should absolutely changed those to match your organization.

Use case

The primary use case as showcased in the 02-full-profile workspace
is building a comprehensive server profile and the component policies. The assumption for the
build is that we are constructing a hypervisor that needs 4 ethernet adapters, 2 fibre channel
adapters, and also has a large pool of local disks to be leveraged as a single RAID6 archive.

Pre-requisites

Required Variables

The following environment variables are required to be set for all Terraform
plans in this repository:

  • TF_VARS_intersight_apikey: The API key with administrative access to the Intersight account
  • TF_VARS_intersight_secretkey: The Secret keyfile contents for the provided API key
  • TF_VARS_c240_m4l_lab_device_id: The serial number for the C-series server being used in this demo

For the full profile Terraform plan 02-full-profile/main.tf, you'll
also need to define these SNMP related security credentials:

  • TF_VAR_snmp_access_community_string: SNMP v1/v2c community string
  • TF_VAR_snmp_trap_community_string: SNMP v1/v2c trap community string

Please refer to the setup-environment-vars.txt file to show a "safe" method for storing the
credentials in your local acount - "safe", of course, in this case with regards to avoiding accidental
commits of your credentials to the Git repository.

How to use this repository

The workspace 01-simple-inventory provides a very minimal
Terraform configuration to simply help you get your core credentials defined, tested, and
also give you some sample Terraform commands and output to help navigate your first time
with Terraform and Intersight.

The workspace 02-full-profile requires a couple more environment
variables (as mentioned above) but will build a comprehensive set of policies and bind them
to a server profile within Intersight.

Wanna stay up to date?

This repository will stay static as a "historical reference" to pair with the Cisco Live session
that can be found at Cisco Live's website. I will be keeping a reasonably
up to date version of this repository in my personal directory:
Introduction to Terraform and Intersight

Feel free to submit issues and/or pull requests against that repository and I'll do my best to
keep things updated.

Use Case

Automating UCS Server Provisioning with Terraform and Intersight

Use Case Statement

The workspace 01-simple-inventory provides a very minimal Terraform configuration to simply help you get your core credentials defined, tested, and also give you some sample Terraform commands and output to help navigate your first time with Terraform and Intersight.

The workspace 02-full-profile provides a comprehensive set of server policies and server profile sufficient to configure a UCS C-series rack mount server (in standalone management mode) that is connected to Intersight as a hypervisor with ethernet, fibre channel, and local storage resources.

Pre-requisites

Clone the Repository and Deploy the Profiles

git clone https://github.com/CiscoSE/BRKDEV-2004-CL21
cd BRKDEV-2004-CL21

# For use case 1 (see README for details)
cd 01-simple-inventory
terraform init
terraform plan
terraform apply
cd ..

# For use case 2 (see README for details, variables are needed!)
cd 02-full-profile
terraform init
terraform plan
terraform apply
cd ..

Required Variables

The following environment variables are required to be set for all Terraform plans in this repository:

  • TF_VARS_intersight_apikey: The API key with administrative access to the Intersight account
  • TF_VARS_intersight_secretkey: The Secret keyfile contents for the provided API key
  • TF_VARS_c240_m4l_lab_device_id: The serial number for the C-series server being used in this demo

For the full profile Terraform plan 02-full-profile/main.tf, you'll also need to define these SNMP related security credentials:

  • TF_VAR_snmp_access_community_string: SNMP v1/v2c community string
  • TF_VAR_snmp_trap_community_string: SNMP v1/v2c trap community string

Please refer to the setup-environment-vars.txt file to show a "safe" method for storing the credentials in your local acount - "safe", of course, in this case with regards to avoiding accidental commits of your credentials to the Git repository.

View code on GitHub

Code Exchange Community

Get help, share code, and collaborate with other developers in the Code Exchange community.View Community
Disclaimer:
Cisco provides Code Exchange for convenience and informational purposes only, with no support of any kind. This page contains information and links from third-party websites that are governed by their own separate terms. Reference to a project or contributor on this page does not imply any affiliation with or endorsement by Cisco.