How can we access the variables defined in host_vars/* files into playbook

Hey there,

I am facing below error when i am trying to access the variables defined in host_vars/ansible.com.

I have defined variable name in host vars file called “ansible.com” like

Your play is targeting 'localhost', but you defined the variable for
the 'ansible.com' host, either move the file to 'localhost' to match
the host name or use the hostvars[<hostname>][<varname>] method to
access variables defined in other hosts.