Skip to main content

Salt -- cheat sheet

     The Salt system is a Python-based open-source remote execution framework for
configuration management, automation, provisioning and orchestration. A basic Salt
implementation consists of a Salt master managing one or more Salt minions.
Salt master:
A server running the salt-master service is a Salt master. The master provides a cohesive
platform for orchestration and automation between managed systems.
Salt minion:
A Salt minion is any system or device managed by Salt. A minion can either run the
salt-minion service or be agent less using salt-ssh or salt-proxy. A minion running the
service may execute commands without a master in stand-alone mode.
Salt proxy:
A Salt Proxy is used to execute commands on devices that are unable to run the minion
service. The proxy minion receives commands from a master, translates and transmits the
commands appropriate to the method of connection to the underlying device
(SSH, REST, etc.), and relays the results back to the master.
Salt SSH:
The Salt SSH system was added as an alternative means to communicate with minions.
It does not require that a minion be present on the target system, only that the
SSH service is running and port 22 is open.

sudo salt-run jobs.lookup_jid $job_id
sudo salt-run jobs.list_jobs search_target='MINION_ID' search_function='state.highstate'
sudo salt-run jobs.exit_success
sudo salt --async *com state.highstate queue=True
sudo salt *com saltutil.refresh_pillar
sudo salt '*'
sudo salt '*' grains.items
sudo salt --async '*' saltutil.sync_all
sudo salt --async '*' state.highstate queue=True
sudo salt '*'
sudo ls -l /opt/saltroots

sudo salt '*' saltutil.refresh_pillar
sudo salt '*' --async state.apply base.base_users_groups

sudo salt '*' state.show_sls

reports minions' running versions and compares them to the master's:
salt-run manage.up
salt-run manage.status
salt-run manage.down

list keys:
salt-key -L

list all running jobs:

| Kill the job:
| kill all jobs:
| salt '*' saltutil.kill_all_jobs
| kill the job with id:
| salt '*' saltutil.kill_job <job id>

test version:
salt '*' test.version

sudo salt minionID 'ls -l /etc' -- remotely run command on MINION
sudo salt minionID 'tail -n100 /var/log/salt/minion'

salt minionID pillar.items

salt-call -l debug state.apply

sudo salt 'host1*' state.apply common.files.files test=True --- OCI
sudo salt 'host1*' state.apply common.files.templates test=True
sudo salt 'host1*' --async state.apply base.base_users_groups.updated_users --- classic
sudo salt --async 'host1*' state.highstate test=True --state-output=changes
sudo salt-call --local --- run local salt command

salt -L `awk -vORS=, '{ print $1 }' min2 | sed 's/,$/\n/'` 'grep "^User" /etc/sudoers'
for i in $(cat min);do sudo salt-key -L|grep ^$i>>min2;done


Popular posts from this blog

Reset root pass in ESXi 5.5

    In this post i will show how to reset root password in ESXi 5.5. For this first we need any bootable linux distributor. In my example i used Ubuntu 16.04.     Boot from Ubuntu disk. Select try Ubuntu, wait for loading. After full loading open Terminal. Type fdisk -l for list all partitions hypervisor/system image is located on the first 250 MB partition (/dev/sda5) which contains the state.tgz file. Mount /dev/sda5 to /mnt sudo -s mount /dev/sda5 /mnt. Go to the /mnt cd /mnt . Copy state.tgz to /tmp folder cp state.tgz /tmp , cd /tmp. Unarchive state.tgz tar xzf state.tgz then   tar xzf local.tgz Go to the /etc directory in /tmp folder  cd etc/ . For deleting resetting password open shadow file with nano shadow  delete the password hash of ESXi root account. Close nano editor. Re add etc/ folder to local.tgz : tar czf local.tgz etc after it readd local.tgz to state.tgz: tar czf state.tgz local.tgz . Copy state.tgz mnt/ folder: cp state.tgz /mnt/ . umount /mnt 

Service Hosting - KVM documentation

Host System Requirements: Minimum host system requirements 6 GB free disk space. 2 GB RAM. Recommended system requirements One core or thread for each virtualized CPU and one for the host. 2 GB of RAM, plus additional RAM for virtual machines. 6 GB disk space for the host, plus the required disk space for the virtual machine(s). KVM Hypervisor Requirements: an Intel processor with the Intel VT-x and Intel 64 virtualization extensions for x86-based systems; or an AMD processor with the AMD-V and the AMD64 virtualization extensions. Installing the Virtualization Packages: To use virtualization on OL7, at minimum, you need to install the following packages: # yum install qemu-kvm libvirt qemu-kvm: This package provides the user-level KVM emulator and facilitates communication between hosts and guest virtual machines. qemu-img: This package provides disk management for guest virtual machines. The qemu-img package is installed as a dependency of the qemu-kvm package. libvirt: