Compare `raw`, `command`, `shell` and `script`.
IntermediateConceptAd-hoc Commands, Modules and Idempotency
Answer
command— run an executable, no shell, needs Python on target.shell— run through/bin/sh(orexecutable:), needs Python.raw— SSH command only, no Python or module payload.script— copy a script from the control node and run it on the target; the script does not need to exist there beforehand.
- ansible.builtin.script: scripts/check.sh --verbose
args:
creates: /var/tmp/check.done
All four are non-idempotent by default. Reach for a real module first.
More on Ad-hoc Commands, Modules and Idempotency
What is an ad-hoc command and what is its syntax?BeginnerWhat does `ansible all -m ping` actually test?BeginnerGive practical use cases for ad-hoc commands.IntermediateWhat is the difference between the `command` and `shell` modules?BeginnerWhy prefer a dedicated module over `shell`/`command`?BeginnerWhat is idempotency and why does it matter?Beginner