saltstack 执行结果返回到mysql

发布时间:2020-08-06 13:45:13 作者:潘阔
来源:网络 阅读:3239

系统:ubuntu 17.04

官方文档https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html

master
(salt-master , mysql,python2.7-mysql)

syndic
(salt-master,mysql-client,salt-syndic,python2.7-mysql)

minion
(salt-minion,mysql-client,python2.7-mysql)

master

#cat /etc/salt/master|grep -v "#" |grep -v "^ *$"
ipv6: False
interface: 192.168.90.177
auto_accept: True
state_top: top.sls
order_masters: True
return: mysql

################################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;

mysql> use salt
mysql> show tables;
+----------------+
| Tables_in_salt |
+----------------+
| jids |
| salt_events |
| salt_returns |
+----------------+

grant all on salt.* to salt@'%' identified by 'salt';

(此为ubuntu上的mysql)
root@jy-KVM1:~# cat /etc/mysql/mysql.conf.d/mysqld.cnf |grep bind
#bind-address = 127.0.0.1 #注释掉,允许其他机器访问

#########################################################################

syndic

#cat /etc/salt/master|grep -v "#" |grep -v "^ *$"
ipv6: False
auto_accept: True
file_roots:
base:

minion

#cat /etc/salt/minion|grep -v "#" |grep -v "^ *$"
master: 192.168.90.178
id: 192.168.90.179
mysql.host: '192.168.90.177'
mysql.user: 'salt'
mysql.pass: 'salt'
mysql.db: 'salt'
mysql.port: 3306

在master上执行

#salt '*' test.ping

查看数据库

6. row
fun: test.ping
jid: 20171204130021772990
return: true
id: 192.168.90.179
success: 1
full_ret: {"fun_args": [], "jid": "20171204130021772990", "return": true, "retcode": 0, "success": true, "fun": "test.ping", "id": "192.168.90.179"}
alter_time: 2017-12-04 13:00:23
6 rows in set (0.01 sec)

ERROR:
No query specified

mysql>

推荐阅读:
  1. saltstack2 grains模块
  2. SaltStack之Job管理和Runner

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

结果 返回 mysql

上一篇:mac升级python版本的方法

下一篇:怎么切换电脑中的输入法

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》