Interview Prep/Ansible/Ad-hoc Commands, Modules and Idempotency

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 (or executable:), 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.

All Ansible questions Roadmap: Ansible

More on Ad-hoc Commands, Modules and Idempotency