Salt stack (salt open) is an opensource utility that can be used to orchestrate vCenter tasks. In this blog, I will guide you on how to install, and set a basic clone operation with salt stack.

Install:

pre-requisite: Linux VM (cent os or ubuntu), I’ve used Ubuntu 20.4 for the below example.

Log into ssh of the ubuntu VM, and add salt stack repository:

wget -O - https://repo.saltstack.com/py3/debian/10/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add -

add key: in /etc/apt/sources.list.d/saltstack.list

nano /etc/apt/sources.list.d/saltstack.list

add the below line on the file:

deb http://repo.saltstack.com/py3/debian/10/amd64/latest buster main

update repository

sudo apt update

install stalt stack

sudo apt-get install salt-master salt-minion salt-ssh salt-syndic salt-cloud salt-api -y

Edit vi /etc/salt/master and add the salt master IP address to interface

interface: 172.16.8.9

Configuring VMware provider

Pre-requisite: Pyvomi must be installed

sudo apt install python3-pip
pip3 install pyVmomi

Confirm pyvomi is imported:

python3 -c "import pyVmomi" ; echo $?

Setup cloud provider:

create /etc/salt/cloud.providers.d/vmware.conf with the below contents: (replace user, password and url as per what you have in your enveronment)

#/etc/salt/cloud.providers.d/vmware.conf
vcsa:
 driver: vmware
 user: '[email protected]'
 password: 'P@ssw0rd'
 url: 'vcsa.ntitta.lab'
 verify_ssl: False 

homelabs:
 driver: vmware
 user: '[email protected]'
 password: '*************'
 url: 'vcsa.ntitta.in'

now you can test the above config by querying for images using below command:

salt-cloud --list-images vcsa

Okay, Now, lets set up profiles: Create /etc/salt/cloud.profiles.d/vmware.conf with the below content:

#/etc/salt/cloud.profiles.d/vmware.conf
ubuntu20:
 provider: vcsa
 clonefrom: ub20
 cluster: vSAN
 ssh_username: root
 password: 'P@ssw0rd'

update salt config

 salt-cloud -u

Test a deployment:

salt-cloud -p ubuntu20 test-stal1-vm

Troubleshooting: (enable debug by using the below )

salt-cloud -p w16k salty-w16-test-1 -l debug

Leave a Reply

Your email address will not be published. Required fields are marked *