command,shell,raw模塊都是ansible遠程執行node服務器的一種指令模式 可是3個模塊的適用仍是有必定的區別html
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
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
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