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 Execution Module Official document https://docs.saltstack.com/en/latest/ref/modules/all/index.html
- How do I add the return of master to the MySQL database?
1) database table structure creation can refer to the third section of http://www.cnblogs.com/shhnwangjian/p/5986964.html "return program"
2) Yum install-y mysql-python Create a Python MySQL module
3) Modify master configuration file
Vi/etc/salt/mastermaster_job_cache:mysqlmysql.host: ' 192.168.137.11 ' mysql.user: ' Salt ' mysql.pass: ' [email Protected] ' mysql.db: ' Salt ' mysql.port:3306
4) Restart Systemctl Restart Salt-master.service
5) Test:
Salt ' * ' test.ping data query select * from salt_returns;
- How do I kill salt in a task that is being performed?
Document Https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.saltutil.html#module-salt.modules.saltutil
Salt ' * ' saltutil.running # view running tasks, find Jid
Salt ' * ' Saltutil.kill_job Jid # Kill task According to Jid
Salt ' * ' Saltutil.clear_cache # Clear Minion Cache
Note:
1) The salt task being performed, the job ID will exist in the/var/cache/salt/minion/proc directory on the Minion side
2) The salt task being performed, based on the configuration of the master cache above, the job path/var/cache/salt/master/jobs directory
Salt Runners
Official Document Https://docs.saltstack.com/en/latest/ref/runners/index.html
Command: Salt-run
Example:
Salt-run jobs.list_jobs # Lists the historical execution tasks currently saved in the job cache Salt-run Jobs.lookup_jid Jid # View history Jid Execution Results
remark: when we execute at the beginning of the Salt command, all the command master is distributed to the Minion side, executed by the Minion side, and if a module exists in master and does not exist on the Minion side, execution failure occurs. To solve this problem, provide the Salt runners module, which is to execute all the commands on the master side.
Salt-run Manage.status # View the status of Minion
Salt-run Manage.downsalt-run Manage.up
Salt-run manage.versions # View version of Minion
Saltstack Job management and runner (eight)