码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack远程执行

时间:2018-12-01 00:13:20      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:tst   default   mission   work   load   ack   无效   nts   ble   

目标 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远程执行

标签:tst   default   mission   work   load   ack   无效   nts   ble   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!