From: Markos Chandras <mchandras@suse.de>
Date: Mon, 16 Apr 2018 09:33:47 +0000 (+0100)
Subject: xci: kubespray: Fix inventory when configuring keys on targethosts
X-Git-Tag: 6.0.0~33^2
X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=e99fb1e677516c2951542d1eee62166246244ca8;p=releng-xci.git

xci: kubespray: Fix inventory when configuring keys on targethosts

The SSH keys for the OPNFV host have been configured in the
configure-opnfvhost.yml playbook so we shouldn't do that in a playbook
that is only meant to configure the target hosts. As such, fix the group
to use 'k8s-cluster' instead.

Since the targethosts playbook does not apply to all hosts anymore, we
can simply drop the list of required packages and only install 'netaddr'
on the OPNFV host which is the host that needs it. Similarly, the dbus
package is only needed on the targethosts.

Change-Id: I293ad83a3a95797d9025f2cddd7849be7b3a49da
Signed-off-by: Markos Chandras <mchandras@suse.de>
---

diff --git a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
index 0ac18b50..9f74892c 100644
--- a/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
+++ b/xci/installer/kubespray/playbooks/configure-opnfvhost.yml
@@ -62,10 +62,13 @@
         insertafter: 'targetPort'
         line: "  type: NodePort"
 
-    - name: pip install ansible
+    - name: pip install required packages
       pip:
-        name: ansible
-        version: "{{ xci_kube_ansible_pip_version }}"
+        name: "{{ item.name }}"
+        version: "{{ item.version | default(omit) }}"
+      with_items:
+        - { name: 'ansible', version: "{{ xci_kube_ansible_pip_version }}" }
+        - { name: 'netaddr' }
 
     - name: Configure SSL certificates
       include_tasks: "{{ xci_path }}/xci/playbooks/manage-ssl-certs.yml"
diff --git a/xci/installer/kubespray/playbooks/configure-targethosts.yml b/xci/installer/kubespray/playbooks/configure-targethosts.yml
index dd7024fb..c744eae6 100644
--- a/xci/installer/kubespray/playbooks/configure-targethosts.yml
+++ b/xci/installer/kubespray/playbooks/configure-targethosts.yml
@@ -1,12 +1,13 @@
 ---
-- hosts: all
+- hosts: k8s-cluster
   remote_user: root
   tasks:
     - name: Manage SSH keys
       include_tasks: "{{ xci_path }}/xci/playbooks/manage-ssh-keys.yml"
-    - name: Install required packages
+
+    - name: Install dbus
       package:
-        name: "{{ kube_require_packages[ansible_pkg_mgr] }}"
+        name: "{{ (ansible_pkg_mgr == 'zypper') | ternary('dbus-1', 'dbus') }}"
         state: present
         update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
 
diff --git a/xci/installer/kubespray/playbooks/group_vars/all b/xci/installer/kubespray/playbooks/group_vars/all
index 87ed63bd..328f8dba 100644
--- a/xci/installer/kubespray/playbooks/group_vars/all
+++ b/xci/installer/kubespray/playbooks/group_vars/all
@@ -1,14 +1,3 @@
-kube_require_packages:
-  apt:
-    - python-netaddr
-    - dbus
-  yum:
-    - python-netaddr
-    - dbus
-  zypper:
-    - python-netaddr
-    - dbus-1
-
 keepalived_ubuntu_src: "uca"
 keepalived_uca_apt_repo_url: "{{ uca_apt_repo_url | default('http://ubuntu-cloud.archive.canonical.com/ubuntu') }}"