Job Management and Runner of SaltStack
Configuration file / etc/salt/master
Cachedir: / var/cache/salt/master # cache path
Keep_jobs: 24 # job save time
Salt executive module official document https://docs.saltstack.com/en/latest/ref/modules/all/index.html
How to add the return of master to the mysql database?
1) for the creation of database table structure, please refer to section 3 "return Program" of http://www.cnblogs.com/shhnwangjian/p/5986964.html.
2) yum install-y MySQL-python creates the mysql module of python
3) modify master configuration file
Vi / etc/salt/mastermaster_job_cache: mysqlmysql.host: '192.168.137.11'mysql.user:' salt'mysql.pass: 'salt@pw'mysql.db:' salt'mysql.port: 3306
Restart systemctl restart salt-master.service
Test:
Salt'* 'test.ping
Query select * from salt_returns in data
How to kill salt the tasks that are being performed?
Document https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.saltutil.html#module-salt.modules.saltutil
Salt'* 'saltutil.running # look at running tasks and find jid
Salt'* 'saltutil.kill_job jid # Kill the mission according to jid
Salt'* 'saltutil.clear_cache # clears the minion cache
Note:
1) for the salt task being executed, the job id will be stored in the / var/cache/salt/minion/proc directory on the minion side.
2) the salt task being executed, according to the configuration of master cache above, under the path / var/cache/salt/master/jobs directory of Job
Salt runners
Official document https://docs.saltstack.com/en/latest/ref/runners/index.html
Command: salt-run
For example:
12salt-run jobs.list_jobs # lists the historical execution tasks currently saved in job cache salt-run jobs.lookup_jid jid # View the results of historical jid execution
Note: when we execute at the beginning of the salt command, all the commands are distributed to the minion side and executed by the minion side. If a module exists in the master but does not exist on the minion side, the execution will fail. To solve this problem, a salt runners module is provided, which executes all commands on the master side.
Salt-run manage.status # View the status of minion
12salt-run manage.downsalt-run manage.up
Salt-run manage.versions # View the version of minion
This article is from http://www.cnblogs.com/shhnwangjian/p/6048891.html