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 '*' grains.ls
sudo salt '*' grains.items
sudo salt --async '*' saltutil.sync_all
sudo salt --async '*' state.highstate queue=True
sudo salt '*' test.ping
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:
salt-run jobs.active

| 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 cmd.run 'ls -l /etc' -- remotely run command on MINION
sudo salt minionID cmd.run '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 cmd.run --- run local salt command

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

Comments

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 

Install Cisco AnyConnect on Ubuntu

Hi   In this post i will show how to  install Cisco AnyConnect on Ubuntu 19.10. First download soft from below link or from cisco.com site https://ftp.tugraz.at/tu-graz/vpn/ Once archive file  downloaded, extract it:     $ tar xvf anyconnect-predeploy-linux-64-3.1.14018-k9.tar.gz cd extracted folder:     $ cd anyconnect-3.1.14018/vpn/ install  Cisco AnyConnect using this command:     $ sudo ./vpn_install.sh After installing you can open application. If application not opening. You have to install libpangox-1.0-0 to solve problem:     $ sudo apt-get install libpangox-1.0-0 That's all.