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

Cheat Sheet

Bash: echo $? - exit status of last command (0 no error) ' - Single quote removes meaning special meaning of special character. find /qwe -type f -iname *.js -exec cp --parents -t /tmp/ {} + -- find all js files and copy with parent directory ystemctl set-default graphical.target (ls -l /lib/systemd/system/runlevel*) -- set runlevel echo <password> | sudo -S for i in t@01 st@02 ba@sta03;do ssh -o RequestTTY=true $i "sudo -l";done -- allow tty present VIM: :r! sed -n '16,812 p' < input_file.txt -- copy line range from input_file :1,10d -- delete line from 1 to 10 :se nu -- show line numbers Apache: Redirection in Apache (By default, the Redirect directive establishes a 302, or temporary, redirect.): URL:https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx <VirtualHost *:80> ServerName www.domain1.com Redirect 301 /oldlocation http://www.domain2.com/newlocation </VirtualHo...

Euro trip. Chapter1: Bucovice-Prague-Nuremberg-Leipzig-Dresden

    Begin to write something every time is complicated for me. Any way i should start. So this trip was somehow unplanned. Where to go, stay ... everything planned on way.    Trip started 2nd of July from Bucovice to Prague. Made reservation on "Hotel Globus" for one night. After check-inn we went to centre walk, see landmarks  of Prague. Additional we have a lunch at asian cafe.     3rd July. Next our plan was drove from Prague to Munich stay one night in camp hostel, visit Munich Zoo. But plans changed on way and we decided drove first Nuremberg to see my friend. Made reservation at "Azimut Hotel". As we arrived earlier check-inn was after 3PM, parked car and we decided not to waste time go and see Nuremberg. We have a lunch some soup and german sausage. And also for 30 euros we took city tour by bus about 2 hour. We saw almost whole city with information (recommended). Evening we meet my friend have a lunch thanks special thanks Fagani. Be...