Saltstack execution results stored to MySQL

Source: Internet
Author: User
Tags create index mysql in saltstack

Saltstack execution results are saved to MySQL for command security audits
Must be an environment above python2.7
Install related modules
Ubuntu System Installation

Apt-get install-y Python-mysqldb

CentOS System Installation

Yum Install-y Mysql-python

database, related table creation, and account creation authorization
Official website: https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html#module-salt.returners.mysql

create DATABASE ' salt ' DEFAULT CHARACTER SET utf8default COLLATE utf8_general_ci; Use ' salt '; CREATE TABLE ' jids ' (' jid ' varchar (255) NOT NULL, ' load ' mediumtext not NULL, UNIQUE KEY ' Jid ' (' Jid ')) Engine=innodb DEFAULT Charset=utf8; CREATE INDEX Jid on Jids (Jid) USING BTREE; CREATE TABLE ' salt_returns ' (' fun ' varchar (#) NOT null, ' jid ' varchar (255) is not NULL, ' return ' mediumtext not NULL, ' ID ' varchar (255) NOT NULL, ' success ' varchar (TEN) NOT null, ' Full_ret ' mediumtext not null, ' Alter_time ' TIMESTAMP Defau LT Current_timestamp, key ' id ' (' id '), key ' Jid ' (' Jid '), key ' fun ' (' fun ')) Engine=innodb DEFAULT Charset=utf8; CREATE TABLE ' salt_events ' (' id ' BIGINT NOT NULL auto_increment, ' tag ' varchar (255) NOT NULL, ' data ' mediumtext not NULL, ' AL Ter_time ' TIMESTAMP DEFAULT current_timestamp, ' master_id ' varchar (255) Not null,primary key (' ID '), key ' tag ' (' tag ')) ENG Ine=innodb DEFAULT Charset=utf8; 

Create a database account and authorize

Grant all privileges the salt.* to [email protected] ' localhost ' identified by ' xxxxxxxx ';

Salt-master Salt-minion Terminal Related configuration
Method One
Add database-related information on all Minion-side configurations
Locate the #return:mysql in the Minion file after you add the database related information
#return: MySQL
Mysql.host: ' 192.168.217.20 '
Mysql.user: ' Salt '
Mysql.pass: ' xxxxx '
Mysql.db: ' Salt '
mysql.port:3306
Reboot so the client

Method Two
Turn on the master side of the Master_job_cache, the method does not need to Minion end configuration database related information, if also configured Minion-side database related information, then the execution results will be stored in the database two copies
The configuration is as follows:

#return: mysqlmaster_job_cache:mysqlmysql.host: ' 192.168.217.20 ' mysql.user: ' Salt ' mysql.pass: ' wclwcw1101! ' Mysql.db: ' Salt ' mysql.port:3306

Restart Salt-master

Saltstack execution results stored to MySQL

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.