New user trying to get Ansible to work for the first time. I setup a hosts file and created a simple ansible.cfg file and a test user. I was trying to use the ping module to test connectivity, but it fails with an authentication error every time. I am able to connect via ssh to the remote hosts with the test user account. I’m not sure what I’m doing wrong at this point. Any ideas would be great.
This will depend on some of your configs and what you’re trying to automate against. I’m assuming you’re attempting to run from the command line and connecting to a Linux host. A couple things to check:
Are you using a password or SSH keys? If the latter, has the key been added to the remote host under the username you’ve setup in Ansible?
Have you confirmed that the hostname in the inventory is valid? This could be an FQDN or IP address.
Looking at your ansible.cfg, inventory and playbook files could help as well as the output of the playbook run (including the command used to run it). Sanitize as needed if there are any passwords, plain text keys or outside IP addresses listed.
I tried to find a getting start guide on the Ansible docs that has details on how to prep your targets hosts but didn’t find anything easy in one place. I’ll take another look later on and send back some links. I would check out Jeff Geerling’s Ansible 101 YouTube series when you have time ( Ansible 101 - YouTube). Great beginner-focused info even though it’s a few years old.
If you are using password authentication you may need to provide it via –ask-pass option for ansible.
If thats not the case, please provide more details like the exact error and possibly error output when running ansible with -vvv option for more verbosity.
I am using password authentication and I am able to connect to both hosts via ssh username@IPADRESS without issue. I can post my ansible.cfg file and the error message later when I’m not at work. There is no sensitive info as I’m just labbing trying to figure out how to use Ansible.
I’m confident this is just me not know where to modify config files or something simple.
I tried the command with --ask-pass and that seemed to work. So can I assume that if I setup key pairs it will work moving forward with just the comman “ansible debian -m ping” ?