How to properly refer to a host from within a role?

203 Views Asked by At

I am currently using in defaults/main.yml:

myRoleName_host: "{{ ansible_host }}"

but some people feel we shouldn't use ansible_host. I know we can reference from host_vars but from within the role you have no guarantee about the host name, so that doesn't seem like a good option. Or should myRoleName_host just be a mandatory variable that the play has to set in order to call the role?

Edit: The goal is to allow the host to be written in the config files/templates that need to be on the server, as well as url variables that the role produces. Other roles depend on these url output variables.

0

There are 0 best solutions below