playbooks_filters_ipaddr.rst: fix syntax, indentation (#65208)
This commit is contained in:
parent
f9f19d171b
commit
a797802d27
1 changed files with 11 additions and 11 deletions
|
@ -268,24 +268,24 @@ In Debian-based systems, the network configuration stored in the ``/etc/network/
|
|||
In the above example, we needed to handle the fact that values were stored in
|
||||
a list, which is unusual in IPv4 networks, where only a single IP address can be
|
||||
set on an interface. However, IPv6 networks can have multiple IP addresses set
|
||||
on an interface::
|
||||
on an interface:
|
||||
|
||||
.. code-block:: jinja
|
||||
.. code-block:: jinja
|
||||
|
||||
# Jinja2 template
|
||||
iface eth0 inet6 static
|
||||
{% set ipv6_list = host_prefix | unique | ipv6('host/prefix') %}
|
||||
address {{ ipv6_list[0] }}
|
||||
{% if ipv6_list | length > 1 %}
|
||||
{% for subnet in ipv6_list[1:] %}
|
||||
up /sbin/ip address add {{ subnet }} dev eth0
|
||||
down /sbin/ip address del {{ subnet }} dev eth0
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% set ipv6_list = host_prefix | unique | ipv6('host/prefix') %}
|
||||
address {{ ipv6_list[0] }}
|
||||
{% if ipv6_list | length > 1 %}
|
||||
{% for subnet in ipv6_list[1:] %}
|
||||
up /sbin/ip address add {{ subnet }} dev eth0
|
||||
down /sbin/ip address del {{ subnet }} dev eth0
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
# Generated configuration file
|
||||
iface eth0 inet6 static
|
||||
address 2001:db8:deaf:be11::ef3/64
|
||||
address 2001:db8:deaf:be11::ef3/64
|
||||
|
||||
If needed, you can extract subnet and prefix information from the 'host/prefix' value::
|
||||
|
||||
|
|
Loading…
Reference in a new issue