The Salt return Receiver (returner) allows the Minion response to be stored in various data stores or in different locations, even displaying the response content on the command line. Returner can be used to extend the salt, and to communicate with new, customized interfaces and support for new databases. This example uses the MySQL store salt to return a value
The operation is as follows:
[email protected] ~]# yum-y Install Mysql-connector-python
[email protected] ~]# yum-y Install mysql-python27
[email protected] ~]# yum-y Install Mysql-server
[email protected] ~]# /etc/init.d/mysqld Start
[email protected] ~]# MySQL
CREATE DATABASE ' Salt '
DEFAULT CHARACTER SET UTF8
DEFAULT COLLATE utf8_general_ci;
Use ' salt ';
DROP TABLE IF EXISTS ' jids ';
CREATE TABLE ' Jids ' (
' Jid ' varchar (255) is not NULL,
' Load ' mediumtext not NULL,
UNIQUE KEY ' Jid ' (' Jid ')
) Engine=innodb DEFAULT Charset=utf8;
DROP TABLE IF EXISTS ' salt_returns ';
CREATE TABLE ' Salt_returns ' (
' Fun ' varchar (+) not NULL,
' Jid ' varchar (255) is not NULL,
' Return ' Mediumtext not NULL,
' ID ' varchar (255) is not NULL,
' Success ' varchar () 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;
DROP TABLE IF EXISTS ' salt_events ';
CREATE TABLE ' salt_events ' (
' ID ' BIGINT not NULL auto_increment,
' Tag ' varchar (255) Not NULL,
' Data ' varchar (1024x768) is not NULL,
' Alter_time ' TIMESTAMP DEFAULT current_timestamp,
PRIMARY KEY (' id '),
KEY ' tag ' (' tag ')
) Engine=innodb DEFAULT Charset=utf8;
Grant all on salt.* to [e-mail protected] ' 172.31.% ' identified by ' salt ';
Flush privileges;
Exit
[email protected] ~]# Vim/etc/salt/master
#return: MySQL
Master_job_cache:mysql
Mysql.host: ' 172.31.24.139 '
Mysql.user: ' Salt '
Mysql.pass: ' Salt '
Mysql.db: ' Salt '
mysql.port:3306
[email protected] ~]# /etc/init.d/salt-master Restart
[email protected] ~]# Salt ' * ' saltutil.refresh_pillar
[email protected] ~]# Salt ' * ' test.ping
[email protected] ~]# MySQL
Use salt;
SELECT * from Salt_returns;
Exit
[Email protected] ~]#
This article is from the "11462293" blog, please be sure to keep this source http://11472293.blog.51cto.com/11462293/1884477
Saltstack (4) return value with MySQL storage salt