Ansible中shell,command,raw模块的区别

command shell raw 模块之间的区别

command,shell,raw模块都是ansible远程执行node服务器的一种指令模式 可是3个模块的适用仍是有必定的区别html

command 模块

The command module takes the command name followed by a list of space-delimited arguments. The given command will be executed on all selected nodes. It will not be processed through the shell, so variables like $HOME and operations like "<", ">", "|", and "&" will not work (use the shell module if you need these features).node

注解:command模块不是调用的shell的指令,因此没有bash的环境变量,也不能使用shell的一些操做方式,其余和shell没有区别python

http://docs.ansible.com/ansible/command_module.html#commandshell

shell 模块

The shell module takes the command name followed by a list of space-delimited arguments. It is almost exactly like the command module but runs the command through a shell (/bin/sh) on the remote node.json

注解:shell模块调用的/bin/sh指令执行bash

http://docs.ansible.com/ansible/shell_module.html服务器

raw 模块

Executes a low-down and dirty SSH command, not going through the module subsystem. This is useful and should only be done in two cases. The first case is installing python-simplejson on older (Python 2.4 and before) hosts that need it as a dependency to run modules, since nearly all core modules require it. Another is speaking to any devices such as routers that do not have any Python installed. In any other case, using the shell or command module is much more appropriate. Arguments given to raw are run directly through the configured remote shell. Standard output, error output and return code are returned when available. There is no change handler support for this module. This module does not require python on the remote system, much like the script module.app

注释:raw不少地方和shell相似,更多的地方建议使用shell和command模块。可是若是是使用老版本python,须要用到raw,又或者是客户端是路由器,由于没有安装python模块,那就须要使用raw模块了ui

http://docs.ansible.com/ansible/raw_module.htmlthis

相关文章
相关标签/搜索