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.
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.
- 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.
- Enter the
salt saltmaster grains.get fqdncommand to idenfity the FQDN of the Salt master.
- Ensure the FQDN is configured for the Salt master by running the ping [FQDN] command.
- On the Salt master, enter python3 to open python.
- 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.
The minion was successfully deployed and configured from your Linux environment and API call.