您的位置:首页 > 其它

远程执行命令

2016-05-06 16:27 183 查看
1、修改配置文件
# vim /etc/ansible/hosts
[testhosts]
127.0.0.1
192.168.32.105

2.执行 command 模块
ansible testhosts -m command -a 'w'
ansible 127.0.0.1 -m command -a 'hostname'

3、报错缺少 libselinux-python
yum -y install libselinux-python

4、用 shell 来执行
ansible slave-puppet.zjcap.cn -m shell -a 'hostname'
ansible slave-puppet.zjcap.cn -m shell -a 'cat /etc/passwd| grep root' 支持管道
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: