Accessing inventory host variable in Ansible playbook

前端 未结 6 1854
夕颜
夕颜 2020-12-03 00:52

I am using Ansible 2.1. I have the following inventory host file and a role being called by a play that needs access to the host file variable. Any thoughts on how to acce

6条回答
  •  旧时难觅i
    2020-12-03 01:11

    You should be able to use the variable name directly

    ansible_ssh_host
    

    Or you can go through hostvars without having to specify the host literally by using the magic variable inventory_hostname

    hostvars[inventory_hostname].ansible_ssh_host
    

提交回复
热议问题