Difference between shell and command in ansible

前端 未结 2 1355
余生分开走
余生分开走 2021-02-18 14:04

I am new to ansible world can anyone help me in understanding the difference between shell and command in ansible. When to use shell and when to use command. I know one use case

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-18 14:24

    according to documentation :

    shell – Execute shell commands on targets

    It is almost exactly like the command module but runs the command through a shell (/bin/sh) on the remote node.

    and:

    command – Execute commands on targets

    The command(s) 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.

    [edited to delete non-decent language]

提交回复
热议问题