diff --git a/ansible/ip-allocation.yml b/ansible/ip-allocation.yml index dd31918eb..81038ed5f 100644 --- a/ansible/ip-allocation.yml +++ b/ansible/ip-allocation.yml @@ -27,6 +27,7 @@ when: - item | net_cidr != None - item | net_bootproto != 'dhcp' + - not item | net_no_ip | bool roles: - role: ip-allocation ip_allocation_filename: "{{ kayobe_env_config_path }}/network-allocation.yml" diff --git a/doc/source/configuration/reference/network.rst b/doc/source/configuration/reference/network.rst index 2ec400e2e..e872e6a48 100644 --- a/doc/source/configuration/reference/network.rst +++ b/doc/source/configuration/reference/network.rst @@ -83,6 +83,9 @@ supported: ``libvirt_network_name`` A name to give to a Libvirt network representing this network on the seed hypervisor. +``no_ip`` + Whether to allocate an IP address for this network. If set to ``true``, an + IP address will not be allocated. Configuring an IP Subnet ------------------------ diff --git a/kayobe/plugins/filter/networks.py b/kayobe/plugins/filter/networks.py index 8ccd21b77..c420675fd 100644 --- a/kayobe/plugins/filter/networks.py +++ b/kayobe/plugins/filter/networks.py @@ -174,6 +174,11 @@ def net_interface(context, name, inventory_hostname=None): return net_attr(context, name, 'interface', inventory_hostname) +@jinja2.contextfilter +def net_no_ip(context, name, inventory_hostname=None): + return net_attr(context, name, 'no_ip', inventory_hostname) + + @jinja2.contextfilter def net_cidr(context, name, inventory_hostname=None): return net_attr(context, name, 'cidr', inventory_hostname) @@ -673,6 +678,7 @@ def get_filters(): 'net_fqdn': _make_attr_filter('fqdn'), 'net_ip': net_ip, 'net_interface': net_interface, + 'net_no_ip': net_no_ip, 'net_cidr': net_cidr, 'net_mask': net_mask, 'net_prefix': net_prefix, diff --git a/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 b/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 index e544e89bc..20f0c6472 100644 --- a/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 +++ b/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 @@ -18,6 +18,7 @@ controller_extra_network_interfaces: - test_net_bridge_vlan - test_net_bond - test_net_bond_vlan + - test_net_bridge_noip # Custom IP routing tables. network_route_tables: @@ -72,6 +73,12 @@ test_net_bond_vlan_interface: "{% raw %}{{ test_net_bond_interface }}.{{ test_ne test_net_bond_vlan_vlan: 44 test_net_bond_vlan_zone: public +# br1: Bridge interface without IP address. +test_net_bridge_noip_cidr: 192.168.40.0/24 +test_net_bridge_noip_interface: br1 +test_net_bridge_noip_bridge_ports: [dummy7] +test_net_bridge_noip_no_ip: true + # Define a software RAID device consisting of two loopback devices. controller_mdadm_arrays: - name: md0 diff --git a/playbooks/kayobe-overcloud-host-configure-base/pre.yml b/playbooks/kayobe-overcloud-host-configure-base/pre.yml index cd791e57d..727e23d8d 100644 --- a/playbooks/kayobe-overcloud-host-configure-base/pre.yml +++ b/playbooks/kayobe-overcloud-host-configure-base/pre.yml @@ -39,4 +39,4 @@ - name: Ensure dummy network interfaces exist command: ip link add dummy{{ item }} type dummy become: true - loop: "{{ range(2, 7) | list }}" + loop: "{{ range(2, 8) | list }}" diff --git a/playbooks/kayobe-overcloud-host-configure-base/tests/test_overcloud_host_configure.py b/playbooks/kayobe-overcloud-host-configure-base/tests/test_overcloud_host_configure.py index 9b535cd16..041015e35 100644 --- a/playbooks/kayobe-overcloud-host-configure-base/tests/test_overcloud_host_configure.py +++ b/playbooks/kayobe-overcloud-host-configure-base/tests/test_overcloud_host_configure.py @@ -87,6 +87,12 @@ def test_network_bond_vlan(host): assert host.file('/sys/class/net/bond0.44/lower_bond0').exists +def test_network_bridge_no_ip(host): + interface = host.interface('br1') + assert interface.exists + assert not '192.168.40.1' in interface.addresses + + def test_additional_user_account(host): user = host.user("kayobe-test-user") assert user.name == "kayobe-test-user" diff --git a/releasenotes/notes/ip-allocation-skip-9e81c13324b7a7e1.yaml b/releasenotes/notes/ip-allocation-skip-9e81c13324b7a7e1.yaml new file mode 100644 index 000000000..3e27c9b91 --- /dev/null +++ b/releasenotes/notes/ip-allocation-skip-9e81c13324b7a7e1.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + The new filter ``net_no_ip`` adds the attribute ``no_ip`` which can be set + to ``true`` to skip IP address allocation and configuration for specific + networks.