您的位置:首页 > 其它

ubuntu安装salt-ssh

2016-02-24 13:26 483 查看
介绍:
salt-ssh 是 0.17.0 新出现的一个功能,一听这名字就知道它是依赖 ssh 来进行远程命令执行的工具,好处就是你不需要在客户端安装 minion,也不需要安装 master(直接安装 salt-ssh 这个包即可),有点类似 paramiko、pssh、ansible 这类的工具,有些时候你还真的需要 salt-ssh(例如:条件不允许安装 minion、不用长期管理某台 minion) 最最重要的是 salt-ssh 并不只是单纯的 ssh 工具,它支持 salt 大部分的功能,如 grains、modules、state 等
备注 需要注意的是,salt-ssh 并没有继承原来的通讯架构 (ZeroMQ),也就是说它的执行速度啥的都会比较慢

安装salt-ssh
root@iZ23f6c5z8tZ:~# apt-get install salt-ssh -y
salt-ssh 是通过调用 roster 配置文件来实现的,语法很简答,定义 ID、host、user、password 即可
root@iZ23f6c5z8tZ:/etc/salt# pwd
/etc/salt
root@iZ23f6c5z8tZ:/etc/salt# ls
master  master.bak  master.d  pki  roster
root@iZ23f6c5z8tZ:/etc/salt# cat roster
# Sample salt-ssh config file
#web1:
#  host: 192.168.42.1 # The IP addr or DNS hostname
#  user: fred         # Remote executions will be executed as user fred
#  passwd: foobarbaz  # The password to use for login, if omitted, keys are used
#  sudo: True         # Whether to sudo to root, not enabled by default
#web2:
#  host: 192.168.42.2
node1:
host: 192.168.1.10
user: root
passwd: xxxooo

格式:
<Salt ID>:    # ID,用于salt-ssh引用
host:     # IP或域名
user:     # 登录用户名
passwd:   # 登录密码
# 可选参数
port:     # 自定义的端口
sudo:     # 是否允许sudo到root,默认不允许
priv:     # ssh登录key路径,默认为salt-ssh.rsa
timeout:  # 等待超时
执行salt-ssh提示需要输入y,那么多要输入y,总不能手动输入吧。
root@iZ23f6c5z8tZ:~# salt-ssh 'node1' -r 'pwd'


解决办法:
root@iZ23f6c5z8tZ:~# touch /root/.ssh/config
root@iZ23f6c5z8tZ:~# cat /root/.ssh/config
host 121.42.137.107 StrictHostKeyChecking no
再次使用salt-ssh
root@iZ23f6c5z8tZ:~# salt-ssh 'node1' -r 'free -m'
node1:
total       used       free     shared    buffers     cached
Mem:          7983        767       7215          0         23        575
-/+ buffers/cache:        168       7815
Swap:            0          0          0


使用salt-ssh安装salt-minion
root@iZ23f6c5z8tZ:~# salt-ssh 'node1' -r 'apt-get install salt-minion -y'
node1:
Reading package lists...
Building dependency tree...
Reading state information...
salt-minion is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 158 not upgraded


本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1744605
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: