Looking at returners recently, it is actually a return module. When executing commands, the results are printed on the screen. returner redirects the results to other places, such as files, databases, and nosql.
Saltstack has many built-in returners modules, such as redis, MySQL, and sqlite3. I will use MySQL as an example here.
The mysqldb Python module and MySQL Server are required.
First, you must configure the database. The saltstack source code shows how to perform the operation.
Create Database 'salt'
Default Character Set utf8
Default collate utf8_general_ci;
Use 'salt ';
Drop table if exists 'jids ';
Create Table 'jkids '(
'Jid' varchar (255) not null,
'Load' mediumtext not null,
Unique key 'jid' ('jid ')
) Engine = InnoDB default charset = utf8;
Drop table if exists 'sale _ returns ';
Create Table 'sale _ returns '(
'Fun 'varchar (50) not null,
'Jid' varchar (255) not null,
'Return 'mediumtext not null,
'Id' varchar (255) not null,
'Success' varchar (10) Not null,
'Full _ RET 'mediumtext not null,
'Alter _ time' timestamp default current_timestamp,
Key 'id' ('id '),
Key 'jid' ('jid '),
Key 'fun '('fun ')
) Engine = InnoDB default charset = utf8;
Grant permissions.
Grant all privileges on salt. * to [email protected] '2017. 192.% 'identified by 'salt ';
Configure minion
The content of MySQL. conf is as follows:
MySQL. HOST: '192. 168.110.132'
MySQL. User: 'salt'
MySQL. Pass: 'salt'
MySQL. DB: 'salt'
MySQL. Port: 3306
Salt-CP '*' mysql. CONF/opt/APP/salt/etc/Minion. d/MySQL. conf
Salt '* 'COMMAND. run'/opt/APP/salt/admin/salt-Minion restart'
Before Execution
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/43/5A/wKioL1PZ393zntLfAABEtio8Vek307.jpg "Title =" qq20140731140954.png "alt =" wkiol1pz393zntlfaabetio8vek307.jpg "/>
Now use the salt operation
Salt '*' test. Ping -- Return MySQL
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/43/5A/wKioL1PZ4IzT-97GAAIC9CQ4sbk072.jpg "Title =" qq20140731141235.png "alt =" wKioL1PZ4IzT-97GAAIC9CQ4sbk072.jpg "/>
There are two records.
Because there are only two machines.
650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/43/5A/wKiom1PZ37Tgam4HAABmgvO744o954.jpg "Title =" qq20140731141337.png "alt =" wkiom1pz37tgam4haabmgvo744o954.jpg "/>
In this way, you can collect statistics on successes and successes in the future.
However, the problem is that the system's built-in returner needs to modify the configuration file and restart minion. If you have already deployed an online application, the cost will be high.
There is no need to modify the configuration. You need to know that the saltstack is very flexible, and you can't do it without the salt. As mentioned in the previous event article, events can be customized with returners.
For more information about event-based custom returner, see the following article.
However, there is another problem. The above returners are suitable for the small architecture of master-minion. If the salt architecture is relatively large and the master-syndic-Minion architecture is used, the master and Minion cannot communicate with each other.
At this time, we need to combine the event for processing, and write a C/S structure program between master-syndic.
I will talk about this next article and write it here first.
References:
Http://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html
Http://www.saltstack.cn/projects/cssug-kb/wiki/Saltstack_master_retuner_over_event_system
This article from the "fly World" blog, please be sure to keep this source http://liuping0906.blog.51cto.com/2516248/1533254