0

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.

2
  • What happens if you add -i /path/to/ansible/hosts to your ansible command?
    – zymhan
    Nov 24, 2015 at 15:55
  • @WildVelociraptor Still uses the local username not ec2-user Nov 24, 2015 at 15:58

1 Answer 1

0

I figured it out. Running ansible --version returned a version prior to the 2.0 release. The current documentation is written for >2.0.

I was able to use ansible_ssh_user=ec2-user which is depreciated in v2.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.