Configure `caas_oam` as flannel interface 88/1688/7
authorKrisztian Lengyel <krisztian.lengyel@nokia.com>
Tue, 1 Oct 2019 12:29:58 +0000 (14:29 +0200)
committerKrisztian Lengyel <krisztian.lengyel@nokia.com>
Fri, 18 Oct 2019 07:46:21 +0000 (09:46 +0200)
Configure `caas_oam` as flannel interface, and fall back to
`infra_internal` if `caas_oam` unspecified.

Change-Id: Id9bdf23cae1510383652aac618c28797426dfed1
Signed-off-by: Krisztian Lengyel <krisztian.lengyel@nokia.com>
SPECS/caas-flannel.spec
ansible/roles/flannel/defaults/main.yaml [new file with mode: 0644]
ansible/roles/flannel/tasks/main.yaml
ansible/roles/flannel/templates/flannel-ds.yaml

index 9dc688f..10c86e9 100644 (file)
@@ -15,7 +15,7 @@
 %define COMPONENT flannel
 %define RPM_NAME caas-%{COMPONENT}
 %define RPM_MAJOR_VERSION 0.11.0
-%define RPM_MINOR_VERSION 10
+%define RPM_MINOR_VERSION 11
 %define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
 
 Name:           %{RPM_NAME}
diff --git a/ansible/roles/flannel/defaults/main.yaml b/ansible/roles/flannel/defaults/main.yaml
new file mode 100644 (file)
index 0000000..61a737d
--- /dev/null
@@ -0,0 +1,26 @@
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+attached_network_profile: "{{ hosts[ansible_hostname]['network_profiles'][0] }}"
+attached_network_profile_data: "{{ hostvars[ansible_hostname]['network_profiles'][attached_network_profile] }}"
+interface_net_mapping: "{{ attached_network_profile_data['interface_net_mapping'] }}"
+
+caas_oam_network: |
+  {% set bound_host_networks = [] %}
+  {% for host_networks in (interface_net_mapping.keys() | map('extract', interface_net_mapping)| list) %}
+      {% set _ = bound_host_networks.extend(host_networks) %}
+  {% endfor %}
+  {% if 'caas_oam' not in bound_host_networks %}infra_internal{% else %}caas_oam{% endif %}
+interface_query: "[*].networking.{{ caas_oam_network | trim }}.interface"
index 19f10d2..03c5775 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+- name: collect flannel interfaces
+  set_fact:
+    flannel_interfaces: "{{ hostvars.values() | json_query(interface_query) | unique | list }}"
+
 - name: template Flannel DaemonSet file
   template:
     src: flannel-ds.yaml
index 901679c..73881e6 100644 (file)
@@ -1,3 +1,4 @@
+#jinja2: lstrip_blocks: True
 {#
 Copyright 2019 Nokia
 
@@ -50,7 +51,9 @@ spec:
         args:
         - --ip-masq
         - --kube-subnet-mgr
-        - --iface={{ networking.infra_internal.interface }}
+        {% for interface in flannel_interfaces | default([]) %}
+        - --iface={{ interface }}
+        {% endfor %}
         securityContext:
           privileged: true
         env: