ansible - ansible'raw','shell'和'command'有什么区别?
问题描述
raw
和in the ansible playbook 有什么shell
区别?command
什么时候用哪个?
解决方案
command:在目标主机上执行远程命令,在其他 playbook 任务的同一 shell 中。
它可用于启动脚本 (.sh) 或执行简单命令。例如:
- name: Cat a file
command: cat somefile.txt
- name: Execute a script
command: somescript.sh param1 param2
shell:在目标主机上执行远程命令,打开一个新的 shell (/bin/sh)。
如果您想执行更复杂的命令,例如与管道连接的命令,可以使用它。例如:
- name: Look for something in a file
shell: cat somefile.txt | grep something
raw:在目标主机上缺少解释器的情况下执行低级命令,一个常见的用例是安装 python。此模块不应在所有其他情况下使用(建议使用命令和 shell)
推荐阅读
- javascript - Node.js 如何获取类方法参数并使用它来调用“this.argument”
- python - Pandas:对于组中的每一行,为一列分配一个值
- java - 无法在 aws 中连接到 Dax 集群
- css - SVG – :hover 和 links 不能与 clip-path 和 Firefox 结合使用
- javascript - 如何将代码修复为可以设置的时钟,使其工作?
- r - chol2inv(chol(x)) 和求解(x)
- flutter - 在图像上手动设置 firebaseStorageDownloadTokens 使用 Flutter 上传到 Firebase 存储
- powerbi - Power BI - 日期切片器不适用于合并查询
- css - 升级后 JSX 样式不适用于 Storybook
- winapi - WIN32:有没有办法让按钮图标(BM_SETIMAGE)出现在文字的右侧