Running playbooks locally
It is important to note that when we talk about running a playbook locally with Ansible, it is not the same as talking about running it on localhost
. If we run a playbook on localhost
, Ansible actually sets up an SSH connection to localhost
(it doesn’t differentiate its behavior or attempt to detect whether a host in the inventory is local or remote—it simply tries faithfully to connect).
Indeed, we can try creating a local
inventory file with the following contents:
[local] localhost
Now, if we attempt to run the ping
module in an ad hoc command against this inventory, we see the following:
$ ansible -i localhosts -m ping all --ask-pass The authenticity of host 'localhost (::1)' can't be established. ECDSA key fingerprint is SHA256:DUwVxH+45432pSr9qsN8Av4l0KJJ+r5jTo123n3XGvZs. ECDSA key fingerprint is MD5:78:d1:dc:23:cc:28:51:42:eb:fb:58:49:ab:92:b6:96. Are you sure you want to continue connecting (yes/no)? yes SSH...