In a play with connection: httpapi, where do the modules actually run, and why does copy: dest=~/file then write the file on the Ansible machine rather than on the firewall?
Network modules run on the Ansible control node itself; only their API calls travel to the device. Ordinary modules in that play (copy, debug, pause) also run locally, so ~/file is the control node's home directory.
With SSH hosts, Ansible copies each module to the managed node and runs it there. Network devices often cannot run Python, so network connection types turn this around: the module runs on the control node, and the connection plugin turns its work into API requests (here HTTPS calls to /web_api/...).
The netcommon connection plugins hand any command or file transfer that is not an API call to a local connection. That is why, in the same play:
debugandpauseprint on the control node, as usual;copy: content=... dest=~/filecreates~/filein the home directory of the user running Ansible, not on the firewall.
This is useful (it is how the lab saves script output and logs locally) but worth knowing: the "host" in the play recap is the management server, while the files land on your own machine.
Go deeper:
How network automation is different: execution on the control node (Ansible docs) — why network modules do not run on the managed device.
copy module (Ansible docs) —
contentanddest.