cyrus 发表于 2018-8-1 06:11:27

Saltstack的返回(return)

所有Minion端的配置文件/etc/salt/minion在最后增加如下几行:  
mysql.host: '10.0.0.7'
  
mysql.user: 'salt'
  
mysql.pass: 'salt'
  
mysql.db: 'salt'
  
mysql.port: 3306
  

  
Use the following mysql database schema(创建数据库):
  
CREATE DATABASE`salt`
  
DEFAULT CHARACTER SET utf8
  
DEFAULT COLLATE utf8_general_ci;
  
USE `salt`;
  
--
  
-- Table structure for table `jids`
  
--
  
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;
  
CREATE INDEX jid ON jids(jid) USING BTREE;
  
--
  
-- Table structure for table `salt_returns`
  
--
  
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;
  
--
  
-- Table structure for table `salt_events`
  
--
  
DROP TABLE IF EXISTS `salt_events`;
  
CREATE TABLE `salt_events` (
  
`id` BIGINT NOT NULL AUTO_INCREMENT,
  
`tag` varchar(255) NOT NULL,
  
`data` mediumtext NOT NULL,
  
`alter_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  
`master_id` varchar(255) NOT NULL,
  
PRIMARY KEY (`id`),
  
KEY `tag` (`tag`)
  
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  
mysql> grant all on salt.* to salt@'%' identified by 'salt';
  
salt-minion配置文件添加一下内容到最后:
  
# vim /etc/salt/minion
  
mysql.host: '10.0.0.7'
  
mysql.user: 'salt'
  
mysql.pass: 'salt'
  
mysql.db: 'salt'
  
mysql.port: 3306
  
# /etc/init.d/salt-minion restart
  
salt-master执行命令:
  
# salt '*' test.ping --return mysql
  
mysql> select * from salt.salt_returns\G
  
*************************** 1. row ***************************
  
       fun: test.ping
  
       jid: 20151123172044880830
  
    return: true
  
      id: linux-node2.example.com
  
   success: 1
  
full_ret: {"fun_args": [], "jid": "20151123172044880830", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "linux-node2.example.com"}
  
alter_time: 2015-11-23 17:20:45
  
1 row in set (0.00 sec)
页: [1]
查看完整版本: Saltstack的返回(return)