diff --git a/ansible/roles_ocp_workloads/ocp4_workload_metallb/defaults/main.yml b/ansible/roles_ocp_workloads/ocp4_workload_metallb/defaults/main.yml index 22b2db6a8a1..35375826e38 100644 --- a/ansible/roles_ocp_workloads/ocp4_workload_metallb/defaults/main.yml +++ b/ansible/roles_ocp_workloads/ocp4_workload_metallb/defaults/main.yml @@ -57,3 +57,7 @@ ocp4_workload_metallb_l2advertisement_ipaddresspool: - "ip-addresspool" ocp4_workload_metallb_l2advertisement_interface: - "br-ex" + +# By default, MetalLB advertises in all nodes. This variable is used to specify in which nodes should be advertised + +ocp4_workload_metallb_node_selector: "" diff --git a/ansible/roles_ocp_workloads/ocp4_workload_metallb/templates/l2advertisement.yaml.j2 b/ansible/roles_ocp_workloads/ocp4_workload_metallb/templates/l2advertisement.yaml.j2 index c5c80c79082..25635ee9fdb 100644 --- a/ansible/roles_ocp_workloads/ocp4_workload_metallb/templates/l2advertisement.yaml.j2 +++ b/ansible/roles_ocp_workloads/ocp4_workload_metallb/templates/l2advertisement.yaml.j2 @@ -6,3 +6,7 @@ metadata: spec: ipAddressPools: {{ ocp4_workload_metallb_l2advertisement_ipaddresspool | to_yaml }} interfaces: {{ ocp4_workload_metallb_l2advertisement_interface | to_yaml }} + {% if ocp4_workload_metallb_node_selector | default("") | length > 0 %} +nodeSelectors: + {{ ocp4_workload_metallb_node_selector | to_yaml }} + {% endif %}