saltstack 用mysql存储 salt 返回值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了saltstack 用mysql存储 salt 返回值相关的知识,希望对你有一定的参考价值。

Salt返回接收器(returner)允许把minion的响应保存在各种数据存储或不同的位置,甚至把响应内容显示在命令行。Returner可以用来扩展Salt,和新的、定制的接口和支持新的数据库进行通信。本例用mysql存储salt返回值 

操作如下:

[[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) 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(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;


DROP TABLE IF EXISTS `salt_events`;

CREATE TABLE `salt_events` (

`id` BIGINT NOT NULL AUTO_INCREMENT,

`tag` varchar(255) NOT NULL,

`data` varchar(1024) NOT NULL,

`alter_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,

PRIMARY KEY (`id`),

KEY `tag` (`tag`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

grant all on salt.* to [email 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] ~]# 

本文出自 “11462293” 博客,请务必保留此出处http://11472293.blog.51cto.com/11462293/1884477

以上是关于saltstack 用mysql存储 salt 返回值的主要内容,如果未能解决你的问题,请参考以下文章

saltstack 缓存清理和数据归档

saltstack项目实战_安装mysql

SaltStack 运行机理特点

salt 执行结果返回mysql

saltstack学习-2 :returnner-将结果发送给syslog和mysql(单边模式)

SaltStack – Using the Mysql Module