|
|
@ -379,9 +379,15 @@ via a role parameter or other input. Variable names can be built by adding stri
|
|
|
|
|
|
|
|
|
|
|
|
{{ hostvars[inventory_hostname]['ansible_' + which_interface]['ipv4']['address'] }}
|
|
|
|
{{ hostvars[inventory_hostname]['ansible_' + which_interface]['ipv4']['address'] }}
|
|
|
|
|
|
|
|
|
|
|
|
The trick about going through hostvars is necessary because it's a dictionary of the entire namespace of variables. 'inventory_hostname'
|
|
|
|
The trick about going through hostvars is necessary because it's a dictionary of the entire namespace of variables. ``inventory_hostname``
|
|
|
|
is a magic variable that indicates the current host you are looping over in the host loop.
|
|
|
|
is a magic variable that indicates the current host you are looping over in the host loop.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
In the example above, if your interface names have dashes, you must replace them with underscores:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: jinja
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{{ hostvars[inventory_hostname]['ansible_' + which_interface | replace('_', '-') ]['ipv4']['address'] }}
|
|
|
|
|
|
|
|
|
|
|
|
Also see dynamic_variables_.
|
|
|
|
Also see dynamic_variables_.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|