As a cloud template developer, you can add properties to the YAML that install the SaltStack Config minion when you deploy the template.

The core properties that you add to the template include remote access for the machine you want to deploy and configuration properties for the SaltStack Config resource. The procedure only includes selected properties. The YAML includes other SaltStack Config resource properties that are not used in this example. For more information, review the schema.

Although this example shows how to add the username and password for the remote access properties, you can configure a secret property and add it to the template. For an example, see Secret Cloud Assembly properties.

Procedure

  1. In Cloud Assembly, select Design > Cloud Templates.
  2. Open an existing template.
  3. Locate the SaltStack Config resource and drag it to the canvas.
  4. Attach the SaltStack Config resource to the machine the minion will be installed on.
  5. In the code pane, add properties to the SaltStack Config resource.

    You are not required to include all of the possible properties. The values used in this example are explained in the table.

    Cloud_SaltStack_1:
        type: Cloud.SaltStack
        properties:
          masterId: saltstack_enterprise_installer
          hosts:
            - ${resource["Cloud_VM_1".id}
          saltEnvironment: sse
          stateFiles:
            - /doe.sls
          variables: 
            user: joe
          additionalMinionParams:
            grains:
              roles:
                - webserver
                - database   
           additionalAuthParams:
             profile:
                tmp_dir: /var/run

    Here is a description of the Cloud_SaltStack_1 properties used in this example.

    Property Description
    masterId In the example schema, the masterId value is saltstack_enterprise_installer.

    You might have master IDs defined in SaltStack Config in Administration > Master Keys

    .
    hosts The hosts value is the ID of the machine or cluster of machines you want to install the minion on. By default, the machine's name is passed in as the minion ID in SaltStack Config.

    It is recommended that you choose machine names that are 15 characters or less, especially if you are deploying minions on Windows. Windows does not permit hostnames that exceed 15 characters.

    If you want to define a custom naming convention for the machines you want to deploy, see Custom naming for deployed resources in Cloud Assembly.

    saltEnvironment In this example, sse is a file location for the state files.

    You might have your state files in other file server locations in SaltStack Config in Config > File Server

    .
    stateFiles In this example, doe.sls is a state file provided in the file server directory specified as the saltEnvironment.
    variables Variables defined in the cloud template are passed as pillars to Salt states. In this example, the variable user is passed to the doe.sls file.

    Variables can be referenced in state files using Jinja, as the following example shows:

    {% set username = pillar.get('user', 'random') %}
    
    friend:
      user.present:
        - names:
          -  {{username}}

    The doe.sls file ensures that a user, represented by the variable user in the cloud template, exists. If the variable is not specified in the cloud template, it ensures the user random is present.

    additionalMinionParams Use this property to pass additional configuration parameters for the minion. These parameters must be passed in as a dictionary:

    • grains: Use this property to assign custom Salt grains to the minion. One or more key:value pairs are accepted. The values can be a string, an array, or a map.

      You can only assign custom grain data when provisioning a new machine. You cannot assign custom grain data when running the Attach SaltStack Resource or Update Salt Configuration day 2 actions.

    additionalAuthParams Use this property to pass additional authorization parameters for provisioning the minion that will be merged/overridden with the default salt-cloud configuration. These parameters must be passed in as a dictionary.

    One or more key:value pairs are accepted as a string, an array, or a map. For an example of how this property is used, see Use Case: How do I deploy minions using the API in a Linux environment.

    Note: You cannot assign additional authorization parameters when running the Update Salt Configuration day 2 action.
  6. Add remoteAccess properties to the machine that hosts the Salt minion.

    If you are deploying a Salt minion to a Linux machine, the value for the authentication key can be usernamePassword or generatedPublicPrivateKey. publicPrivateKey is unsupported.

    If you are deploying a Salt minion to a Windows machine, the value for the authentication key must be usernamePassword..

     remoteAccess:
            authentication: usernamePassword
            username: adminUser
            password: adminPassword
  7. Verify that your YAML includes the properties similar to the following sample.
    resources:
      Cloud-Network:
        type: Cloud.Network
        properties:
          networkType: existing 
      Cloud_VM_1:
        type: Cloud.vSphere.Machine
        properties:
          image: ubuntu
          flavor: small
          remoteAccess:
            authentication: usernamePassword
            username: adminUser
            password: adminPassword
          networks:
            - network: ${resource["Cloud-Network"].id}
      Cloud_SaltStack_1:
        type: Cloud.SaltStack
        properties:
          masterId: saltstack_enterprise_installer
          hosts:
            - ${resource["Cloud-VM-1"].id}
          saltEnvironment: sse
          stateFiles:
            - /doe.sls
          variables: 
            user: joe
          additionalMinionParams:
            grains:
              roles:
                - webserver
                - database
  8. Test and deploy the cloud template.
    If your minion deployment fails, see Troubleshoot minion deployments.
  9. Verify the Salt Configuration properties for the deployed machine.
    1. Select Deployments > Deployments and open the deployment details.
    2. On the Topology tab, click the machine and expand the Salt Configuration properties in the right-hand pane.

      Screenshot of the Topology tab with the Salt Configuration properties expanded in the right pane. The properties include the Master ID, Salt environment, and state files.

Verify the minion in SaltStack Config

After you install the minion on the virtual machine, locate the minion and run any jobs or commands on the resource.

Procedure

  1. To open SaltStack Config, click the applications menu in the upper-right corner and click Cloud Services Console.
  2. Click the SaltStack Config service tile.
  3. In SaltStack Config, expand Minion Keys and click Accepted.
  4. In the Minion ID column, click the filter icon and enter the name of the minion.
    The minion's name defaults to the virtual machine's hostname. In this example, the minion ID is salt-vm-010.
    Screenshot of the Accepted minion keys in SaltStack Config.
  5. To view the details, click the minion's name.
    You can run jobs or commands on the minion. For example, Sample Disk Usage. This job returns disk usage statistics for a minion.
    Screenshot of the details page for the sample minion ID

View Salt grain data

After you finish deploying a Salt minion on your virtual machines, you can view the minion's grains in Cloud Assembly.

Salt grains are collected for the minion's operating system, domain name, IP address, kernel, OS type, memory, and many other system properties. If you do not have access to SaltStack Config, or want to quickly view grain data without leaving the Cloud Assembly user interface, you can use the Topology tab to view grain data. See Salt grains to learn more about grain data.

To view a minion's grains:

  1. In Cloud Assembly, select Resources > Deployments, and locate your deployment.
  2. On the Topology tab, select the virtual machine that is attached to the SaltStack Config resource.
  3. Locate the Salt Configuration section in the right pane and scroll down to view the list of grain data.Screenshot of grain data in Cloud Assembly

A minion's grain data is retrieved after you deploy the minion. To see when the grain data was last updated, you can scroll to the bottom of the Salt Configuration section.

Screenshot of the last updated grain data in Cloud Assembly
Note: The grain data only updates if you run the day 2 Update Salt Configuration action on a SaltStack Config resource. It will not update if any changes are made outside of Cloud Assembly.