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.
- Deploy a Salt Minion to a new Machine
- Configure the Master Server on newly deployed Minions
- Add a custom Grain to new Minions
- 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”.
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.
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.
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:
- Define the input
- Inject the input into the SaltStack resource.
- 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.
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.