Saltstack Job management and runner (eight)

Source: Internet
Author: User
Tags python mysql saltstack

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.