标签:saltstack 返回
1、安装依赖(操作只在master端)
yum -y install MySQL-python
2、master端本地数据库中创建对应的表结构
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;
3、更新salt的master配置文件
[root@localhost salt]# pwd /etc/salt [root@localhost salt]# egrep -v ‘^$|^#‘ master default_include: master.d/*.conf interface: 192.168.24.66 auto_accept: True file_roots: base: - /srv/salt pillar_roots: base: - /srv/salt/pillar return: mysql mysql.host: ‘192.168.24.66‘ mysql.user: ‘salt‘ mysql.pass: ‘salt‘ mysql.db: ‘salt‘ mysql.port: 3306 master_job_cache: mysql //使用此选项后,就不需要minion端配置
4、测试返回
[root@localhost ~]# salt ‘*‘ cmd.run ‘df -h‘ --return mysql 192.168.24.67: Filesystem Size Used Avail Use% Mounted on /dev/sda3 93G 4.4G 84G 5% / tmpfs 1.9G 12K 1.9G 1% /dev/shm /dev/sda1 190M 146M 31M 83% /boot 192.168.24.68: Filesystem Size Used Avail Use% Mounted on /dev/sda3 93G 4.4G 84G 5% / tmpfs 1.9G 12K 1.9G 1% /dev/shm /dev/sda1 190M 146M 31M 83% /boot
已经写入数据库
标签:saltstack 返回
原文地址:http://tianruyun.blog.51cto.com/4549660/1795687