What is the difference between a module and an action plugin?
AdvancedConceptAd-hoc Commands, Modules and Idempotency
Answer
A module runs on the target host. An action plugin runs on the control node, before (or instead of) the module, and can do work locally. Many familiar modules are really action plugin plus module pairs.
template renders the Jinja2 file on the control node (action plugin) and then calls the copy module to transfer the result. copy and unarchive read local files in the same way. include_tasks, debug, set_fact, assert and add_host run entirely on the controller.
This is why template functions like lookup and variables from your inventory work inside templates, and why ansible_facts of the target are available only because they were collected and sent back earlier.
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?BeginnerCompare `raw`, `command`, `shell` and `script`.IntermediateWhy prefer a dedicated module over `shell`/`command`?Beginner