Welcome to the Linux Foundation Forum!

Help with YAML


I just started playing around with YAML two days ago and have ran into a problem I can't figure out. My set up is three VMs within VirtualBox. I'm using one VM as my YAML controller, and the other two as plain hosts/targets for my testing.

Here's what I'm working with. I have a playbook named myplay.yml that holds the following:

[osboxes@ansible controller test_project]$ cat myplay.yml

name: Test connectivity
hosts: all
- name: Ping tests

Then a simple hosts file:

[osboxes@ansible controller test_project]$ cat myhosts

I run the following command and see this error message:

[osboxes@ansible controller test_project]$ ansible-playbook myplay.yml -i myhosts

PLAY [Test connectivity] ******************************************************************************************

TASK [Gathering Facts] ********************************************************************************************
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", "unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", "unreachable": true}
to retry, use: --limit @/home/osboxes/test_project/myplay.retry

PLAY RECAP ******************************************************************************************************** : ok=0 changed=0 unreachable=1 failed=0 : ok=0 changed=0 unreachable=1 failed=0

I can ssh to both hosts from my VM acting as the controller (the VM where ansible is installed and where I'm running the commands from). What is bugging me is why is it trying to ssh to these hosts when all I'm doing is running a ping test?????

Any input is appreciated.




  • serewicz
    serewicz Posts: 1,000


    We do not use ansible in this course. Perhaps you posted in the wrong course?

    Also notice that the error you posted says " ssh: Permission denied", which would cause me to investigate what SSH info the ansible user uses, as distinct from your own user. Commands such as ps and strace may be helpful to investigate the details of the eventual SSH command.

    Please let me know if you would like me to move this question to some other course.


  • hikerguy62

    Apologies. I didn't realize this was a course-related forum. I did end up fixing it by using the following in the myhosts file:

    target1 ansible_host= ansible_user=osboxes ansible_ssh_pass=osboxes.org
    target2 ansible_host= ansible_user=osboxes ansible_ssh_pass=osboxes.org

    You can delete or move if you like.




Upcoming Training