I am trying to use juniper_junos_facts from the Ansible Junos module to query some VM's that I provisioned using Vagrant. However I am getting the following error.
fatal: [r1]: FAILED! => {"changed": false, "msg": "Unable to make a PyEZ connection: ConnectUnknownHostError(r1)"}
fatal: [r2]: FAILED! => {"changed": false, "msg": "Unable to make a PyEZ connection: ConnectUnknownHostError(r2)"}
I see in the following document Here on juniper.net that this error occurs when you don't have the host defined correctly in the inventory file. I don't believe this to be an issue with my inventory file because when I run ansible-inventory --host all appears to be in order
~/vagrant-projects/junos$ ansible-inventory --host r1
{
    "ansible_ssh_host": "127.0.0.1", 
    "ansible_ssh_port": 2222, 
    "ansible_ssh_private_key_file": ".vagrant/machines/r1/virtualbox/private_key", 
    "ansible_ssh_user": "root"
}
~/vagrant-projects/junos$ ansible-inventory --host r2
{
    "ansible_ssh_host": "127.0.0.1", 
    "ansible_ssh_port": 2200, 
    "ansible_ssh_private_key_file": ".vagrant/machines/r2/virtualbox/private_key", 
    "ansible_ssh_user": "root"
}
My playbook is copied from the following document which I got from Here on juniper.net.
My Inventory File
[vsrx]
r1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_private_key_file=.vagrant/machines/r1/virtualbox/private_key
r2 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2200 ansible_ssh_private_key_file=.vagrant/machines/r2/virtualbox/private_key
[vsrx:vars]
ansible_ssh_user=root
My Playbook
---
- name: show version
  hosts: vsrx
  roles:
    - Juniper.junos
  connection: local
  gather_facts: no
  
  tasks:
    - name: retrieve facts
      juniper_junos_facts:
        host: "{{ inventory_hostname }}"
        savedir: "{{ playbook_dir }}"
    - name: print version
      debug:
        var: junos.version