From ff9529243553675b7b73022713638327cd7ffda9 Mon Sep 17 00:00:00 2001
From: Etienne Champetier <champetier.etienne@gmail.com>
Date: Fri, 8 Jan 2021 19:01:05 -0500
Subject: [PATCH] calico: fix warnings (#7121)

TASK [network_plugin/calico : Calico | Configure calico network pool] **********
task path: /builds/kargo-ci/kubernetes-sigs-kubespray/roles/network_plugin/calico/tasks/install.yml:138
Friday 08 January 2021  17:10:12 +0000 (0:00:01.521)       0:11:36.885 ********
[WARNING]: The value {'kind': 'IPPool', 'apiVersion': 'projectcalico.org/v3',
'metadata': {'name': 'default-pool'}, 'spec': {'blockSize': 24, 'cidr':
'10.233.64.0/18', 'ipipMode': 'Always', 'vxlanMode': 'Never', 'natOutgoing':
True}} (type dict) in a string field was converted to "{'kind': 'IPPool',
'apiVersion': 'projectcalico.org/v3', 'metadata': {'name': 'default-pool'},
'spec': {'blockSize': 24, 'cidr': '10.233.64.0/18', 'ipipMode': 'Always',
'vxlanMode': 'Never', 'natOutgoing': True}}" (type string). If this does not
look like what you expect, quote the entire value to ensure it does not change.

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
---
 roles/network_plugin/calico/tasks/install.yml | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/roles/network_plugin/calico/tasks/install.yml b/roles/network_plugin/calico/tasks/install.yml
index 1d785436a..7c8ce8a31 100644
--- a/roles/network_plugin/calico/tasks/install.yml
+++ b/roles/network_plugin/calico/tasks/install.yml
@@ -138,6 +138,8 @@
 - name: Calico | Configure calico network pool
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       { "kind": "IPPool",
         "apiVersion": "projectcalico.org/v3",
@@ -171,6 +173,8 @@
 - name: Calico | Set up BGP Configuration
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       { "kind": "BGPConfiguration",
       "apiVersion": "projectcalico.org/v3",
@@ -181,7 +185,7 @@
           "logSeverityScreen": "Info",
           {% if not calico_no_global_as_num|default(false) %}"asNumber": {{ global_as_num }},{% endif %}
           "nodeToNodeMeshEnabled": {{ nodeToNodeMeshEnabled|default('true') }} ,
-          {% if calico_advertise_cluster_ips|default(false) %}"serviceClusterIPs": [{"cidr": {{ kube_service_addresses }} }],{% endif %}
+          {% if calico_advertise_cluster_ips|default(false) %}"serviceClusterIPs": [{"cidr": "{{ kube_service_addresses }}" }],{% endif %}
           "serviceExternalIPs": {{ _service_external_ips|default([]) }} }}
   changed_when: false
   when:
@@ -190,6 +194,8 @@
 - name: Calico | Configure peering with router(s) at global scope
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       {"apiVersion": "projectcalico.org/v3",
       "kind": "BGPPeer",
@@ -213,6 +219,8 @@
 - name: Calico | Configure peering with route reflectors at global scope
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       {"apiVersion": "projectcalico.org/v3",
       "kind": "BGPPeer",
@@ -236,6 +244,8 @@
 - name: Calico | Configure route reflectors to peer with each other
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       {"apiVersion": "projectcalico.org/v3",
       "kind": "BGPPeer",
@@ -310,6 +320,8 @@
 - name: Calico | Configure node asNumber for per node peering
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       {"apiVersion": "projectcalico.org/v3",
       "kind": "Node",
@@ -335,6 +347,8 @@
 - name: Calico | Configure peering with router(s) at node scope
   command:
     cmd: "{{ bin_dir }}/calicoctl.sh apply -f -"
+    stdin: "{{ stdin | to_json }}"
+  vars:
     stdin: >
       {"apiVersion": "projectcalico.org/v3",
       "kind": "BGPPeer",
-- 
GitLab