Another reason to adopt Visual Studio Code for Infrastructure as Code
Tue, 17 Sep 2024 12:59:07 -0000
|Read Time: 0 minutes
New extension on Visual Studio Code
Visual Studio Code (VS Code) is a widely popular, lightweight source code editor developed by Microsoft, used by over 24 million developers worldwide. With its flexibility, extensive language support, and powerful extension ecosystem, VS Code has become the preferred choice for developers across many fields, from web development to infrastructure management.
I’m excited to introduce the Dell Infrastructure as Code (IaC) Snippets extension for Visual Studio Code. You can locate this extension within the extensions search section of the VS Code interface. This extension provides over 2,000 lines of pre-built snippet code designed to help you quickly implement Ansible modules and Terraform resources related to Dell infrastructure. It simplifies the process of automating CRUD operations on Dell systems, reducing the time needed to find and write examples. Please note that this is my personal contribution to the DevOps ecosystem and there is no Dell Support for the extension.
The Dell IaC Snippets extension allows you to easily browse available modules and resources, making it much easier to get started with Dell infrastructure automation without having to dig through documentation.
Get Started
Step 1: Install the Dell IaC Snippets extension from the Visual Studio Code extension search:
Step 2: Start using it! For Ansible, open a .yml file and type pscale, pstore, or pflex to see a list of modules available. From there, select one and begin configuring your infrastructure right away.
Note: If your environment is on a remote SSH host, you can enable the plugin to work on the remote host also:
Ansible configurations
Here is how the Ansible snippets appear for the different modules of Dell’s enterprise storage products, PowerScale, PowerFlex, and PowerStore:
The list is automatically filtered based on what you type after the initial shortcut:
Select any of the modules and view a comprehensive example for the particular module configuration:
Terraform configuration
The snippets also support Dell Terraform provider for PowerScale (PowerFlex coming soon). You do need the Hashicorp Terraform extension to provide support for the Hashicorp Configuration Language (HCL) which is also free and can be installed in a single step.
To see the resources available, create a .TF file and use pscale as a prefix for the snippets. Right at the cursor you’ll see the list of resources available:
Once selected you can see the snippet for the resource. You can configure the resource block depending on the CRUD operation you are performing on the resource:
Note that some of the resource snippets are more than hundred lines, most of which are commented lines of parameters available to configure for the resource. Once you set the resource configuration as needed you can delete the rest of the commented parameters.
Putting snippets to work in your environment
Here are a few things to note about the snippets:
- The snippet is a generic example for the module/resource being configured which can be modified to perform CRUD operations depending on whether the resource already exists and the values for the state of the resource. Declarative paradigms like Ansible and Terraform allow easy editing of the example to the configuration state.
- To help discover the parameters you can configure, I have included comments with default values and possible values.
- Parameters that are less frequently used have been entirely commented out. However, you can enable these by selecting the relevant lines and pressing Ctrl+/.
- Many of the parameter values are variables that you can set in a vars file. When it comes to access credentials in Ansible, I used references such as:
<<: *powerscale_credentials #use pscale-creds (to view PowerScale credentials)
Here, you can see how this reference is defined using the creds snippet like pscale-creds:
NOTE: This extension is my personal contribution to the Dell DevOps community and is not supported by Dell technical support channels. You can reach out to me on LinkedIn for support. I will also consider publishing the source code on GitHub in the near future depending on community needs.
VS Code for AI powered DevOps
As this blog title suggests, let’s now review some of the other key reasons why VS Code is such a popular tool when it comes to DevOps and ITOps workflows:
Free and Open-Source
VS Code is completely free and open source, with a large community actively contributing extensions and features. This means it's constantly evolving, with new tools and extensions being released regularly.
Extensive Language (and IaC) Support
With support for numerous programming languages, ranging from popular ones like Python and JavaScript to more specialized ones, VS Code can handle just about any project, making it an all-in-one solution for developers. For those working with infrastructure automation tools like Ansible or Terraform, VS Code provides a growing set of extensions, including the new Dell IaC Snippets extension, to streamline infrastructure management. These tools make it easy to write and test code for configuring servers, storage, and other resources.
Remote Development Tools
Features including remote SSH, and dev containers enable developers to work directly on remote machines or containers as if they were local environments. This is especially useful for working with remote or cloud servers, WSL on a Windows PC, development containers, or even IoT devices. In fact, there is an extension pack in VS Code that install the following extensions which are a must have.
Integrated Version Control with GitHub
VS Code comes with integrated Git and GitHub support, allowing you to manage repositories, commit code, and collaborate with others directly from the editor. You can also review pull requests and manage issues without switching to a separate tool. You can do this either using the Git commands on CLI or using the side pane of the GUI.
AI-Powered Code Assistance
Using applications like GitHub Copilot and Codeium, developers can leverage AI to write code faster and with fewer errors. These assistants help suggest code, contain autocomplete functions, and even assist in debugging. See this video to see how coding assistants can accelerate your configuration management and observability workflows with Dell OpenManage Enterprise as an example.
Conclusion
To wrap things up, VS Code offers a modern, efficient environment for both coding and infrastructure management. With the Dell IaC Snippets extension, it's now easier to automate Dell infrastructure tasks directly from your editor, providing you with a simple way to get started and scale your automation efforts. I hope you give it a try!
Author: Parasar Kodati, Staff Technologist, Dell ISG