What is the implicit localhost and how does it behave?

IntermediateConceptInventory
Answer

If localhost is not in your inventory, Ansible still lets you target it with hosts: localhost. It uses ansible_connection=local, and the Python interpreter that runs Ansible (rather than SSH). It does not belong to all or any group, so hosts: all will not include it.

- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
    - ansible.builtin.debug: msg="control node tasks"

It is commonly used for cloud API calls, such as creating infrastructure before the real hosts exist.

All Ansible questions Roadmap: Ansible

More on Inventory