ansible - 在 ansible 中,何时使用 shell vs 脚本模块来运行 shell 脚本

标签 ansible

我有一个 shell 脚本——我可以在本地主机上同时使用 shell 模块和脚本模块来执行它。一个比另一个有什么优势?

来自 https://docs.ansible.com/ansible/latest/modules/script_module.html#examples ,看起来脚本模块也将脚本复制到远程主机,然后在那里执行。因此,我假设对于本地主机或者如果脚本已经远程存在,我是否正确,两者之间没有区别。

最佳答案

shell 模块只能访问远程机器上已经存在的脚本。 scripte-module 将脚本从本地主机复制到远程机器并执行它。如果脚本同时存在于本地主机和远程计算机上,您可以使用其中任何一个(如果您使用正确的路径)。如果 localhost 是您的剧本的目标,那么情况总是如此。

关于ansible - 在 ansible 中,何时使用 shell vs 脚本模块来运行 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55013692/

相关文章:

ansible - 从 Ansible 中的两个字典列表中选择值

ansible - 使用 Ansible 检查 HTTP 资源的最佳方法是什么?

ansible - 是否可以在 list 文件中添加ansible_ssh_common_args

ansible - 在 lineinfile 模块中使用文件名和文件内容的变量

用于解压的 ansible 本地文件路径

Ansible:使用变量定义 playbook 主机

centos - Ansible 的 yum 模块中可用的两个 "state"选项值 "present"和 "installed"之间有什么区别?

ansible - 在单个 playbook 上运行主机 B 上的任务之前,等待主机 A 上的任务完成

amazon-web-services - 'ansible_date_time' 未定义

powershell - 在 Windows 上通过 Ansible 安装 Chocolatey 时出错