Difference between shell and command in ansible

前端 未结 2 1347
余生分开走
余生分开走 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:25

    The Ansible Shell Module allows you to run arbitrary commands on a remote host, just like you were logged into the shell. The Shell and Command modules are very similar, the major difference being that the shell module does not escape commands, allowing you to use shell operators like redirects ("greater than", "less than"), pipe ("|") and boolean operators ("&&", "||"). This does mean that the Shell module is susceptible to command injection/shell injection, but this is easy enough to overcome by using the "quote" filter when using variables with the Shell module.

    Reference: Ansible Shell Module Tutorial - Complete Beginner's Guide

提交回复
热议问题