首页 > 其他 > 详细

saltstack远程执行

时间:2018-11-30 23:57:28      阅读:301      评论:0      收藏:0      [点我收藏+]
目标 https://docs.saltstack.com/en/latest/ 模块 https://docs.saltstack.com/en/latest/ref/modules/all/index.html salt ‘*‘ service.available sshd 验证sshd服务 [root@master ~]# grep -v ‘^$‘ /etc/salt/master |grep -v ‘#‘ client_acl: #客户端开启模块限制 luo: #用户名 - test.ping - network.* file_roots: base: - /srv/salt pillar_roots: base: - /srv/pillar [root@master ~]# systemctl restart salt-master 给用户授权 [root@master ~]# useradd luo useradd:用户“luo”已存在 [root@master ~]# passwd luo 更改用户 luo 的密码 。 新的 密码: 无效的密码: 密码少于 8 个字符 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。 [root@master ~]# su - luo [luo@master ~]$ salt ‘*‘ test.ping [WARNING ] Failed to open log file, do you have permission to write to /var/log/salt/master? 192.168.43.71: True 192.168.43.118: True 返回 把返回结果,放进数据库:https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.mysql.html#module-salt.returners.mysql [root@master ~]# mysql -pMyNewPass4! mysql>CREATE DATABASE `salt` DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; USE `salt`; mysql>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; mysql>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; mysql>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> use salt; Database changed mysql> show tables; +----------------+ | Tables_in_salt | +----------------+ | jids | | salt_events | | salt_returns | +----------------+ mysql> grant all on salt.* to salt@‘%‘ identified by ‘Myq1231!‘; [root@master ~]# yum -y install MySQL-python #minion返回,所有minion都装 [root@master ~]# grep -v ‘^$‘ /etc/salt/master |grep -v ‘#‘ client_acl: luo: - test.ping - network.* file_roots: base: - /srv/salt pillar_roots: base: - /srv/pillar mysql.host: ‘192.168.43.118‘ mysql.user: ‘salt‘ mysql.pass: ‘Myq1231!‘ mysql.db: ‘salt‘ mysql.port: 3306 [root@master ~]# systemctl restart salt-master [root@master ~]# salt ‘*‘ test.ping --return mysql [root@slave ~]#grep -v ‘^$‘ /etc/salt/minion |grep -v ‘#‘ master_job_cache: mysql master: 192.168.43.118 mysql.host: ‘192.168.43.118‘ mysql.user: ‘salt‘ mysql.pass: ‘Myq1231!‘ mysql.db: ‘salt‘ mysql.port: 3306 [root@master ~]# grep -v ‘^$‘ /etc/salt/minion |grep -v ‘#‘ master_job_cache: mysql master: 192.168.43.118 mysql.host: ‘192.168.43.118‘ mysql.user: ‘salt‘ mysql.pass: ‘Myq1231!‘ mysql.db: ‘salt‘ mysql.port: 3306 [root@master ~]# systemctl restart salt-minion mysql> select * from salt_returns;

saltstack远程执行

原文:http://blog.51cto.com/13399294/2324549

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!