Skip to content

Commit e2aadb3

Browse files
committed
Skip IP address allocation and configuration if needed
Sometimes some hosts should be configured with an interface without any IP address set (e.g. bridged interface) and to achieve that this change adds the new attribute 'no_ip' for the network configuration. Also the change contain a test for this. Change-Id: I2c9dfeca7f0d37a96f9cbd9df51d94098cf07258 Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com> (cherry picked from commit 1de4f2a)
1 parent 9af442e commit e2aadb3

File tree

7 files changed

+30
-1
lines changed

7 files changed

+30
-1
lines changed

ansible/ip-allocation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
when:
2828
- item | net_cidr != None
2929
- item | net_bootproto != 'dhcp'
30+
- not item | net_no_ip | bool
3031
roles:
3132
- role: ip-allocation
3233
ip_allocation_filename: "{{ kayobe_env_config_path }}/network-allocation.yml"

doc/source/configuration/reference/network.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ supported:
8383
``libvirt_network_name``
8484
A name to give to a Libvirt network representing this network on the seed
8585
hypervisor.
86+
``no_ip``
87+
Whether to allocate an IP address for this network. If set to ``true``, an
88+
IP address will not be allocated.
8689

8790
Configuring an IP Subnet
8891
------------------------

kayobe/plugins/filter/networks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ def net_interface(context, name, inventory_hostname=None):
174174
return net_attr(context, name, 'interface', inventory_hostname)
175175

176176

177+
@jinja2.contextfilter
178+
def net_no_ip(context, name, inventory_hostname=None):
179+
return net_attr(context, name, 'no_ip', inventory_hostname)
180+
181+
177182
@jinja2.contextfilter
178183
def net_cidr(context, name, inventory_hostname=None):
179184
return net_attr(context, name, 'cidr', inventory_hostname)
@@ -670,6 +675,7 @@ def get_filters():
670675
'net_fqdn': _make_attr_filter('fqdn'),
671676
'net_ip': net_ip,
672677
'net_interface': net_interface,
678+
'net_no_ip': net_no_ip,
673679
'net_cidr': net_cidr,
674680
'net_mask': net_mask,
675681
'net_prefix': net_prefix,

playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ controller_extra_network_interfaces:
1818
- test_net_bridge_vlan
1919
- test_net_bond
2020
- test_net_bond_vlan
21+
- test_net_bridge_noip
2122

2223
# Custom IP routing tables.
2324
network_route_tables:
@@ -67,6 +68,12 @@ test_net_bond_vlan_cidr: 192.168.39.0/24
6768
test_net_bond_vlan_interface: "{% raw %}{{ test_net_bond_interface }}.{{ test_net_bond_vlan_vlan }}{% endraw %}"
6869
test_net_bond_vlan_vlan: 44
6970

71+
# br1: Bridge interface without IP address.
72+
test_net_bridge_noip_cidr: 192.168.40.0/24
73+
test_net_bridge_noip_interface: br1
74+
test_net_bridge_noip_bridge_ports: [dummy7]
75+
test_net_bridge_noip_no_ip: true
76+
7077
# Define a software RAID device consisting of two loopback devices.
7178
controller_mdadm_arrays:
7279
- name: md0

playbooks/kayobe-overcloud-host-configure-base/pre.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
- name: Ensure dummy network interfaces exist
4040
command: ip link add dummy{{ item }} type dummy
4141
become: true
42-
loop: "{{ range(2, 7) | list }}"
42+
loop: "{{ range(2, 8) | list }}"

playbooks/kayobe-overcloud-host-configure-base/tests/test_overcloud_host_configure.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ def test_network_bond_vlan(host):
8181
assert host.file('/sys/class/net/bond0.44/lower_bond0').exists
8282

8383

84+
def test_network_bridge_no_ip(host):
85+
interface = host.interface('br1')
86+
assert interface.exists
87+
assert not '192.168.40.1' in interface.addresses
88+
89+
8490
def test_additional_user_account(host):
8591
user = host.user("kayobe-test-user")
8692
assert user.name == "kayobe-test-user"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
features:
3+
- |
4+
The new filter ``net_no_ip`` adds the attribute ``no_ip`` which can be set
5+
to ``true`` to skip IP address allocation and configuration for specific
6+
networks.

0 commit comments

Comments
 (0)