VMware Aria Automation Config Cloud Automation SaltStack Config VMware Aria Automation Assembler vRealize Automation

Getting Started with SaltStack Config: SaltStack integration in Aria Automation Templates

In this part of the “Getting Started with SaltStack Config” series, we will show you how to use SaltStack from within Aria Automation Templates. This will give you a solid foundation for automating your cloud infrastructure with SaltStack.

By the end of this article, you will know how to use SaltStack in Aria Automation Templates.

For this purpose, we will examine the following parts in more detail.

  1. Deploy a Salt Minion to a new Machine
  2. Configure the Master Server on newly deployed Minions
  3. Add a custom Grain to new Minions
  4. Apply a state during the provisioning process, including custom variable

Before you can start designing a new Template, the environment must be prepared for the SaltStack integration.

The first step is to add SaltStack in to Aria Automation as a new integration endpoint. This will allow you to use SaltStack resources in Templates in a later step.

For more detailed documentation, including a list of all prerequisites, please visit the official documentation at: https://docs.vmware.com/en/vRealize-Automation/8.10/Using-and-Managing-Cloud-Assembly/GUID-5555BD8D-506C-40C9-8CE9-138297FB8F30.html

Deploying the Salt Minion

There are several ways to deploy a Minion to a new machine. In our case, we will use a method called “saltify”, which is triggered by an API call from Aria Automation to the integrated SaltStack Config environment. More information about the API approach can be found on the VMware documentation pages: https://docs.vmware.com/en/VMware-vRealize-Automation-SaltStack-Config/SaaS/using-and-managing-saltstack-config-guide/GUID-A032E42A-C2ED-447D-ADFA-17B08576FC22.html

To do this, add a new SaltStack resource to the Template canvas. SaltStack resources can be found in the left menu area. Simply drag and drop the element and connect the SaltStack resource to the virtual machine resource. Aria Automation will automatically update the YAML code.

Once this is done, an error will appear on the canvas and in the YAML code. This is because the SaltStack resource requires additional configuration.

The default value for the masterId property is “SaltStack_enterprise_installer”. The value can be added as a static variable in the YAML code or used as a property.

If you don’t know which value to assign to your masterID, log in to your SaltStack Config UI and go to “Administration/ Master Keys”.

Now, every time the Template is deployed, it will install the Salt Minion and automatically approve it in the SaltStack environment.
For each deployed Minion, under Activity/Completed, the following two activities will appear in the list of completed actions:
  • deploy.minion
  • key.accept
A closer look into each of these two activities will reveal what happened during the execution. Just click on the job ID on the very right of the activity list (the long number), to see the job details.

Deploying the Minion on new virtual machines is the first step, applying a specific state which configures the newly deployed machine is the next.

Applying a state to new deployments

States can be simply added by editing the YAML file. The SaltSack resource which is added to the YAML has a mandatory state property for this purpose. This property requires an array. This array can be left empty if no state should be applied, otherwise the state name must be defined. When specifying the state, it must be defined as the full tree path. In addition to the state path, the target environment must be specified.

So far so good, the new machine has a Minion and a state applied. But SaltStack can do much more. Imagine that a state runs a configuration that depends on certain attributes of the machine. These individual attributes could be stored in a Grain configured for the new machines.

Customize the Minion configuration with Grains

If your first thought is to run a complicated script or command line, you’ll notice that Aria Automation and SaltStack can make your life so much easier.

The SaltStack resource has an additional feature for adding Grains. Take a look at the following example to see how to set a Grain.

Let’s put the finishing touches on the Template and let the user provide some input.

Get user input and pass it to SaltStack states

In Aria Automation, inputs for the request can be defined which a user can fill in when he or she requests the service.

Imagine a Template that provisions a web server, and the requestor wants to be able to modify the welcome line of the new web server’s homepage with the application name.

To transfer the input via the Template to the Salt state, three things are required:

  1. Define the input
  2. Inject the input into the SaltStack resource.
  3. Inject the input variable into the state.

Item number one on the list is perhaps the easiest step. Here is an example of YAML for the application name input:

To use this in the Salt state, add the input value as a property into the SaltStack resource.

For this purpose, the SaltStack resource provides a property called “variables”. This property requires a key-value pair, where the key defines the name of the variable which will be used in the upcoming Salt state, and the value is, of course, the value.
Now it’s time to switch into SaltStack Config UI and inject the user input into the state file.
Input parameters are treated like Pillar data, you can work with inputs the same way as you read Pillar data.  
The following example replaces the string “replace me” in the web server’s index file. Pay attention to line 19, which uses the notation ” {{ pillar[‘applicationName’]}} ” to define and read the input variable from the Template when state is applied.

SaltStack is a powerful tool for automating and configuring cloud services. Its integration with Aria Automation will make your life so much easier, allowing you to provision new virtual machines with one click, customize them with one state, and add custom Grains to individualize them. All of this can be done without writing a single line of script or a complex command line.