From 704d1340fb09b5ffad0282bc143d41e2afebd0bf Mon Sep 17 00:00:00 2001
From: Yujun Zhang <zhang.yujunz@zte.com.cn>
Date: Tue, 16 May 2017 15:13:14 +0800
Subject: Add support for manually installed (not using installer) OPNFV pod

Change-Id: I314882dd8a9e491f253f825a8da7ec4c91ed3321
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
---
 resources/ansible_roles/qtip-workspace/defaults/main.yml       |  1 +
 .../qtip-workspace/files/template/group_vars/all.yml           |  1 +
 resources/ansible_roles/qtip-workspace/files/template/hosts    |  9 +++++++++
 resources/ansible_roles/qtip-workspace/files/template/run.yml  |  4 ++--
 .../ansible_roles/qtip-workspace/files/template/setup.yml      | 10 ++++++++--
 .../ansible_roles/qtip-workspace/files/template/teardown.yml   |  2 +-
 .../qtip-workspace/files/template/templates/hosts              |  9 ++++++---
 7 files changed, 28 insertions(+), 8 deletions(-)

(limited to 'resources')

diff --git a/resources/ansible_roles/qtip-workspace/defaults/main.yml b/resources/ansible_roles/qtip-workspace/defaults/main.yml
index 68dafbc2..7f6407d3 100644
--- a/resources/ansible_roles/qtip-workspace/defaults/main.yml
+++ b/resources/ansible_roles/qtip-workspace/defaults/main.yml
@@ -12,6 +12,7 @@ installer: fuel
 installer_master_host: fuel-master
 
 installer_master_group:
+  manual: dummy-group
   fuel: fuel-masters
   apex: apex-underclouds
 
diff --git a/resources/ansible_roles/qtip-workspace/files/template/group_vars/all.yml b/resources/ansible_roles/qtip-workspace/files/template/group_vars/all.yml
index 2967f6eb..3d41e1b4 100644
--- a/resources/ansible_roles/qtip-workspace/files/template/group_vars/all.yml
+++ b/resources/ansible_roles/qtip-workspace/files/template/group_vars/all.yml
@@ -14,6 +14,7 @@ qtip_dump: dump
 qtip_cache: "{{ qtip_cache }}"
 qtip_workdir: "{% raw %}{{ ansible_env.HOME }}{% endraw %}/qtip-workdir-{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}"
 installer_master_group:
+  manual: dummy-group
   fuel: fuel-masters
   apex: apex-underclouds
 
diff --git a/resources/ansible_roles/qtip-workspace/files/template/hosts b/resources/ansible_roles/qtip-workspace/files/template/hosts
index b8b4bbe6..b8b256a9 100644
--- a/resources/ansible_roles/qtip-workspace/files/template/hosts
+++ b/resources/ansible_roles/qtip-workspace/files/template/hosts
@@ -1,4 +1,13 @@
 localhost   ansible_connection=local
 
+{% if installer != 'manual' %}
 [{{ installer_master_group[installer] }}]
 {{ installer_master_host }}
+{% else %}
+[SUT]
+# Add hosts in system under test, example::
+#
+#   host-1  ansible_host=192.168.10.1 ansible_host=22 ansile_user=root
+#
+# See http://docs.ansible.com/ansible/intro_inventory.html for details
+{% endif %}
\ No newline at end of file
diff --git a/resources/ansible_roles/qtip-workspace/files/template/run.yml b/resources/ansible_roles/qtip-workspace/files/template/run.yml
index 9bb865d6..f8e71f0c 100644
--- a/resources/ansible_roles/qtip-workspace/files/template/run.yml
+++ b/resources/ansible_roles/qtip-workspace/files/template/run.yml
@@ -16,14 +16,14 @@
   - { role: qtip, tasks: setup-local, tags: [setup] }
 
 
-- hosts: compute
+- hosts: SUT
 
   roles:
   # prepare environment
   - { role: qtip, tasks: setup-node, tags: [setup] }
 
 
-- hosts: compute
+- hosts: SUT
 
   roles:
   # run test and collect metrics
diff --git a/resources/ansible_roles/qtip-workspace/files/template/setup.yml b/resources/ansible_roles/qtip-workspace/files/template/setup.yml
index a522d67b..d165a9fe 100644
--- a/resources/ansible_roles/qtip-workspace/files/template/setup.yml
+++ b/resources/ansible_roles/qtip-workspace/files/template/setup.yml
@@ -10,8 +10,14 @@
 # Prepare connection to SUT (System Under Test)
 
 ---
-
-- hosts: [fuel-masters, apex-underclouds]
+{% if installer == 'manual' %}
+- hosts: localhost
+  gather_facts: no
+  tasks:
+    - debug: "msg='please add hosts to SUT group in `hosts` file manually.'"
+{% else %}
+- hosts: [{{ installer_master_group[installer] }}]
   gather_facts: no
   roles:
     - { role: qtip, tasks: generate-inventory }
+{% endif %}
diff --git a/resources/ansible_roles/qtip-workspace/files/template/teardown.yml b/resources/ansible_roles/qtip-workspace/files/template/teardown.yml
index cd0b9a2c..dc659930 100644
--- a/resources/ansible_roles/qtip-workspace/files/template/teardown.yml
+++ b/resources/ansible_roles/qtip-workspace/files/template/teardown.yml
@@ -7,7 +7,7 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-- hosts: compute
+- hosts: SUT
 
   roles:
   # teardown environment
diff --git a/resources/ansible_roles/qtip-workspace/files/template/templates/hosts b/resources/ansible_roles/qtip-workspace/files/template/templates/hosts
index cbbfcfef..492651b0 100644
--- a/resources/ansible_roles/qtip-workspace/files/template/templates/hosts
+++ b/resources/ansible_roles/qtip-workspace/files/template/templates/hosts
@@ -4,12 +4,15 @@ localhost   ansible_connection=local
 [{{ installer_master_group[installer] }}]
 {{ installer_master_host }}
 
-[fuel-groups:children]
+[SUT]   # system under test
+compute
+
+[node-groups:children]
 {% for group in hosts|sort %}
 {{ group }}
 {% endfor %}
 
-[fuel-groups:vars]
+[node-groups:vars]
 ansible_ssh_common_args=-F ./ssh.cfg
 
 {% for group in hosts|sort %}
@@ -19,4 +22,4 @@ ansible_ssh_common_args=-F ./ssh.cfg
 {% endfor %}
 
 {% endfor %}
-{% endraw %}
\ No newline at end of file
+{% endraw %}
-- 
cgit