From f72470b570382f565c7d82a21cbafed0767d9fbe Mon Sep 17 00:00:00 2001
From: Manuel Buil <mbuil@suse.com>
Date: Mon, 12 Aug 2019 12:18:21 +0200
Subject: Set the correct labels for noha

In noha mode, node1 and node2 is used for controller and compute roles.
This patch changes that making node1 only controller and node2 only
compute.
It also modifies a bit the syntax to make it more ansible friendly

deploy-scenario:k8-calico-nofeature
installer-type:osh

Change-Id: I3f40f59ea3c167914ea4c810f7dda60c75fb7175
Signed-off-by: Manuel Buil <mbuil@suse.com>
---
 .../roles/prepare-opnfvhost-osh/tasks/main.yml     | 16 ++-------------
 .../roles/prepare-opnfvhost-osh/vars/main.yml      | 24 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 14 deletions(-)

(limited to 'xci')

diff --git a/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/tasks/main.yml b/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/tasks/main.yml
index b31dc706..72ae821f 100644
--- a/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/tasks/main.yml
+++ b/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/tasks/main.yml
@@ -4,21 +4,9 @@
   changed_when: false
 
 - name: Set kubernetes node labels
-  shell: "for x in `kubectl get nodes --show-labels | grep 'node-role.kubernetes.io/node=true' | awk '{print $1}'`; do kubectl label nodes $x {{ item }}; done"
-  args:
-    executable: /bin/bash
+  command: "kubectl label nodes {{ item }} {{ node_labels[item]|join(' ') }}"
   changed_when: false
-  with_items:
-    - openstack-control-plane=enabled
-    - openstack-compute-node=enabled
-    - openstack-helm-node-class=primary
-    - openvswitch=enabled
-    - linuxbridge=enabled
-    - ceph-mon=enabled
-    - ceph-osd=enabled
-    - ceph-mds=enabled
-    - ceph-mgr=enabled
-    - ceph-rgw=enabled
+  with_items: "{{ groups['kube-node'] }}"
 
 - name: Create directories
   file:
diff --git a/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/vars/main.yml b/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/vars/main.yml
index 53188bdb..b40b5afb 100644
--- a/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/vars/main.yml
+++ b/xci/installer/osh/playbooks/roles/prepare-opnfvhost-osh/vars/main.yml
@@ -5,3 +5,27 @@ required_packages:
 - jq
 - nmap
 - bc
+
+node_labels:
+  node1:
+    - openstack-control-plane=enabled
+    - openstack-compute-node={{ (xci_flavor == 'mini') | ternary('enabled', 'disable') }}
+    - openstack-helm-node-class=primary
+    - openvswitch=enabled
+    - linuxbridge=enabled
+    - ceph-mon=enabled
+    - ceph-osd=enabled
+    - ceph-mds=enabled
+    - ceph-mgr=enabled
+    - ceph-rgw=enabled
+  node2:
+    - openstack-control-plane={{ (xci_flavor == 'noha') | ternary('disable', 'enabled') }}
+    - openstack-compute-node=enabled
+    - openstack-helm-node-class=primary
+    - openvswitch=enabled
+    - linuxbridge=enabled
+    - ceph-mon=enabled
+    - ceph-osd=enabled
+    - ceph-mds=enabled
+    - ceph-mgr=enabled
+    - ceph-rgw=enabled
-- 
cgit