avhimkov
3/20/2017 - 1:09 PM

ansible_local_connect.yaml

Ansible by default tries to connect through ssh. For localhost you should set the connection to local

You can define this when calling the playbook:

ansible-playbook playbook.yml --connection=local
Define it in your playbook:

- hosts: local
  connection: local
Or, preferable, define it as a host var just for localhost/127.0.0.1. Create a file host_vars/127.0.0.1 relative to your playbook with this content:

ansible_connection: local
You also could add it as a group var in your inventory:

[local]
127.0.0.1

[local:vars]
ansible_connection=local
or as a host var:

[local]
127.0.0.1   ansible_connection=local

[nginx:vars]
ansible_ssh_private_key_file = <YOUR PRIVATE KEY LOCATION>
[app:vars]
ansible_ssh_private_key_file = <YOUR 2nd PRIVATE KEY LOCATION>

[nginx:children]
nginx_servers

[app:children]
app_servers

[nginx_servers]
1.2.3.4
[app_servers]
5.5.5.5
6.6.6.6