Ansible on Localhost
From bib. source
When running playbooks on the server or workstation where the task needs to be run (e.g., self-provisioning), or when a playbook should be otherwise run on the same host as the
ansible-playbookcommand is run, you can use--connection=localto speed up playback execution by avoiding the SSH connection overhead.
When using an Ansible ad-hoc command, specifically the ansible-playbook command (refer to 20250514154644-Running_Ansible_Playbooks), the use of the connection option, taking a value of local, allows the playbook to be run without the SSH connection session overhead (Geerling 2023, 116). This is useful especially in cases wherein one is trying to run an Ansible playbook or execute an Ansible play on the local machine rather than a remote server or hostname / FQDN / public IP address.
ad-hoc_command ad-hoc_commands command_line command_lines command_line_interface command_line_interfaces Secure_Shell_protocol fully_qualified_domain_name fully_qualified_domain_names IP_address Internet_Protocol_address Internet_Protocol
bibliography
- “Ansible Playbooks - Beyond the Basics.” In Ansible for DevOps: Server and Configuration Management for Humans, 2nd ed., 84–122. Leanpub, 2023.