Add documentation for routed interfaces

Using the container_(extra)_networks hash a user can define a routed
interface for a network without an address. This change documents that
capability.

Change-Id: I93bdfde1aa5a9820d1853a779caf6670ee58d335
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-08-20 18:49:10 -05:00
parent ca6fe7df8d
commit 7ba42bc3d7
2 changed files with 10 additions and 1 deletions

View File

@ -33,6 +33,8 @@ nspawn_networks:
netmask: 255.255.255.0
# Optional | Set the macvlan mode
macvlan_mode: bridge
# Optional | set the routed interface
routed_interface: mv-nspawn0
# Primary interface used for host to container communications. In the event that
# the underlying system is running a condensed network stack a route will be
@ -57,6 +59,7 @@ nspawn_networks:
# + simple example:
# management_cidr: "172.29.236.0/24"
# storage_cidr: "10.0.0.0/24"
# flat_cidr: "172.29.239.0/24"
# container_networks:
# management_address:
# bridge: eth0
@ -66,6 +69,10 @@ nspawn_networks:
# netmask: 255.255.255.0
# tunnel_address:
# bridge: eth0.10
# flat_address:
# bridge: eth0
# interface: mv-flat
# routed_interface: mv-flat
#
# Extra interfaces that are wholly configured by the user can be set using the
# container extra networks option. This option follows all of the parameters of
@ -80,6 +87,8 @@ container_extra_networks: {}
# assigned to the underlying interface, "eth0".
# + The tunnel network will be attached to the container and isolated from the
# host with no access to without first attaching to the container.
# + The flat network will be created and attached to the container with a host
# route on the defined `routed_interface`.
#
nspawn_primary_interface: "{{ nspawn_networks['nspawn_address']['bridge'] }}"

View File

@ -101,7 +101,7 @@
{%- set _ = start_commands.append('-/sbin/ip link set dev ' + mv_interface + ' up') %}
{% if hostvars[inventory_hostname][key.split('_')[0] + '_cidr'] is defined and (value.address is undefined) %}
{% set net_cidr = hostvars[inventory_hostname][key.split('_')[0] + '_cidr'] %}
{% set _ = start_commands.append('-/sbin/ip route add ' + net_cidr + ' dev ' + nspawn_primary_interface + ' metric 100 proto kernel scope link table local') %}
{% set _ = start_commands.append('-/sbin/ip route add ' + net_cidr + ' dev ' + (value.routed_interface | default(nspawn_primary_interface)) + ' metric 100 proto kernel scope link table local') %}
{% elif (value.address is defined) and ((interface_data['ipv4'] | default({'address': none}))['address'] != value.address) %}
{% set _ = start_commands.append('-/sbin/ip address add ' + value.address + '/' + (value.netmask | default('32')) + ' dev ' + mv_interface + ' scope host') %}
{%- endif %}