[Ansible]script模块

  • 将管理节点的脚本上传至被管理节点执行,理论上此模块不许需要被管理服务器上有python
[root@ceph1 ~]# cat a.sh
touch /tmp/ansible-script

[root@ceph1 ~]# ansible webservers -m script -a "a.sh"
ceph3 | CHANGED => {
    "changed": true,
    "rc": 0,
    "stderr": "Shared connection to ceph3 closed.\r\n",
    "stderr_lines": [
        "Shared connection to ceph3 closed."
    ],
    "stdout": "",
    "stdout_lines": []
}

[root@ceph1 ~]# ansible webservers -m shell -a "ls -l /tmp/ | grep ansible"
ceph3 | CHANGED | rc=0 >>
drwx------  2 root root       41 9月  14 11:50 ansible_command_payload_kxNYUy
-rw-r--r--  1 root root        0 9月  14 11:48 ansible-script

END

posted @ 2020-09-14 14:57  LeoShi2020  阅读(1261)  评论(0编辑  收藏  举报