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.
More on Inventory
What is an inventory and why does Ansible need one?BeginnerWhat are the INI and YAML inventory formats and how do they differ?BeginnerHow do you create groups of groups?BeginnerExplain host patterns: `:`, `:&`, `:!` and wildcards.IntermediateWhich connection variables can you set per host in inventory?BeginnerWhat are `group_vars` and `host_vars` directories?Intermediate