内容简介:ansible 的 command 和 shell 模块都可以执行命令,例如:但是如果你使用 command 运行一些包含特殊符号的命令,比如“|” “<” “>” 之类的命令就无法执行,原因我们通过查看
ansible 的 command 和 shell 模块都可以执行命令,例如:
➜ www ansible k8s-master -m command -a 'pwd' kubernetes-1 | SUCCESS | rc=0 >> /root ➜ www ansible k8s-master -m shell -a 'pwd' kubernetes-1 | SUCCESS | rc=0 >> /root
但是如果你使用 command 运行一些包含特殊符号的命令,比如“|” “<” “>” 之类的命令就无法执行,原因我们通过
ansible-doc command
查看
Notes:
* If you want to run a command through the shell (say you are using `<', `>', `|', etc), you actually want the [shell]
module instead. The `command' module is much more secure as it's not affected by the user's environment.
* `creates', `removes', and `chdir' can be specified after the command. For instance, if you only want to run a
command if a certain file does not exist, use this.
因此在使用的时候需要注意了。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Node.js模块系统 (创建模块与加载模块)
- 黑客基础,Metasploit模块简介,渗透攻击模块、攻击载荷模块
- 022.Python模块序列化模块(json,pickle)和math模块
- 024.Python模块OS模块
- 023.Python的随机模块和时间模块
- Laravel 模块化开发模块 – Caffienate
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
构建高可用Linux服务器(第3版)
余洪春 / 机械工业出版社 / 2014-10 / 79.00元
《构建高可用Linux服务器(第3版)》是Linux运维领域公认的经典畅销书,是国内51CTO、IT168等知名网站和多位资深运维专家共同推荐的运维工程师必备的工具书! “酒哥”在Linux运维领域潜心实践近10年,一直在运维一线,技术和思维都紧跟时代的发展,非常清楚运维工程师们需要什么,应该学习什么。本书不仅是他近10年工作经验的结晶,同时也是他的数万名读者和数十万粉丝共同需求和集体智慧的......一起来看看 《构建高可用Linux服务器(第3版)》 这本书的介绍吧!