0
点赞
收藏
分享

微信扫一扫

ansible远程执行脚本


1.先在服务端创建一个 shell 脚本

[root@localhost ~]$ cat /tmp/test.sh 
#!/bin/bash
echo "hello world"

2.把脚本分发到客户端

[root@localhost ~]$ ansible 192.168.56.100 -m copy -a "src=/tmp/test.sh dest=/tmp/test.sh mode=0755"

3.远程执行脚本,使用 shell 模块

[root@localhost ~]$ ansible 192.168.56.100 -m shell -a "/tmp/test.sh"
192.168.56.100 | CHANGED | rc=0 >>
hello world

版权声明:本文为博主原创文章,未经博主允许不得转载。

ansible

举报

相关推荐

0 条评论