I’m trying to get Ansible up and running for the first time. For some reason, the parameters I have added to my hosts file are not being used when I run a command like
ansible all -m ping
It tries to ping the two hosts in the file but uses my local username rather than the one specified in the hosts file.
I have the following hosts file:
[dev] xx.5.xxx.1xx ansible_user=ec2-user ansible_ssh_private_key_file=~/Documents/AWSKeys/myKey1.pem mysite.theweb.com ansible_user=ec2-user ansible_ssh_private_key_file=~/Documents/AWSKeys/myKey2.pem
However, if I pass in the parameters in the command itself, it works just fine.
This is successful:
ansible all -m ping -u ec2-user
The keys are loaded into the SSH agent.
I want to use the hosts file to add a lot of machines with different keys so I really need to get this working.
-i /path/to/ansible/hoststo your ansible command?