The goal of this use case is to programmatically install the Salt minion service on a minon by connecting a Linux VM to your SaltStack Config environment.

Prerequisites

Before you can deploy a minion using the API in a Linux environment you must:
  • Have a SaltStack Config evironment with RaaS deployed.
  • Have a Salt master and Salt minion installed.
  • Have a Linux VM deployed.

Procedure

  1. Verify that the folder etc/salt/cloud.deploy.d on the Salt master contains these files.
    Note: The xxxx in the file name, for example salt-xxxx-readhat-8-x86_64-amd64.tar.gz, should match the version of the Salt master. To verify the version of the Salt master, run the salt-master -V command on the Salt master.
  2. Enter the salt saltmaster grains.get fqdn command to idenfity the FQDN of the Salt master.
  3. Ensure the FQDN is configured for the Salt master by running the ping [FQDN] command.
  4. On the Salt master, enter python3 to open python.
  5. Enter this API call with the correct credentials for your environment:
    from sseapiclient import APIClient
    
    client = APIClient('https://<master-ip>', '<ssc-username>', '<sscpassword>', ssl_validate_cert=False)
    
    
    client.api.minions.deploy_minion(
    
     master_id = '<master-id>',
    
     host_name_ip = '<prospective minion’s ip>',
    
     os = ‘<prospective minion’s os>’,
    
     minion_id = '<desired-minion-name-for-prospective-minion>',
    
     username = '<ssh-username-for-prospective-minion>', 
    
     password = '<ssh-password-for-prospective-minion>',
    
    )
    The deploy.minion function begins running in your SSC environment. You can verify this in the Activity tab of the SSC user interface.

Results

The minion was successfully deployed and configured from your Linux environment and API call.

What to do next

Verify the minion was deployed successfully by running a test.ping command against the minion using the Run Command window or by running the \* test.ping and \* test.versions commands in the Salt master command window.