Ansible 的 command 和 shell 模块

栏目: 服务器 · 发布时间: 7年前

内容简介: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.

因此在使用的时候需要注意了。


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

网站运维技术与实践

网站运维技术与实践

饶琛琳 / 电子工业出版社 / 2014-3 / 69.00元

网站运维工作,一向以内容繁杂、覆盖面广著称。《网站运维技术与实践》选取日常工作涉及的监测调优、日志分析、集群规划、自动化部署、存储和数据库等方面,力图深入阐述各项工作的技术要点及协议原理,并介绍相关开源产品的实践经验。在技术之外,作者也分享了一些关于高效工作及个人成长方面的心得。 《网站运维技术与实践》适合Linux 系统管理员、中大型网站运维工程师及技术负责人、DevOps 爱好者阅读。同......一起来看看 《网站运维技术与实践》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具