I am using Ansible 2.1.1.0 intalled by pip on OS X "El capitan". And I have tried with a very simple configuration:
#/etc/ansible/hosts
[webservers]
my.remote.server
Using the variable ansible_user to connect through ssh using the corresponding public key:
#/etc/ansible/group_vars/webservers
---
ansible_user: my_user
All seems to be fine when I try to ping the server ansible webservers -m ping
:
my.remote.server | SUCCESS => {
"changed": false,
"ping": "pong"
}
Nonetheless when I try to run any command on the remote server it gets executed on my local machine, for example running ansible webservers -m shell -a "echo $HOSTNAME"
should display my.remote.server, but displays this instead:
my.remote.server | SUCCESS | rc=0 >>
my.local.server
Any idea what could be causing the issue?