Ansible: get non-default ipv6.address from global scope

Jan 12, 2017 12:59

Set 'iface' to something meaningful for your case in host_vars or group_vars, e.g. 'em1' or 'eth1'. Here is how you get it in Jinja2 template:

{% for v6 in hostvars[host]['ansible_' + hostvars[host]['iface']].ipv6 %}
{% if v6.scope == 'global' %}
  {{ v6.address }} - is your global IPv6 address on that interface.
{% endif %}
{% endfor %}

administrating linux

Previous post Next post
Up