Refactoring connection task 83/33283/3
authorYujun Zhang <zhang.yujunz@zte.com.cn>
Wed, 12 Apr 2017 04:14:59 +0000 (12:14 +0800)
committerYujun Zhang <zhang.yujunz@zte.com.cn>
Wed, 12 Apr 2017 08:09:45 +0000 (16:09 +0800)
- split `compute` playbook into `setup` and `run`
- save inventory and ssh configuration after in `setup`

Change-Id: I0803a954ffcd7c07861ff6bdb76acdbfaa4815bd
Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
tests/integration/hosts [deleted file]
tests/integration/hosts.j2 [new file with mode: 0644]
tests/integration/hosts.sample [new file with mode: 0644]
tests/integration/run.yaml [moved from tests/integration/compute.yaml with 84% similarity]
tests/integration/setup.yaml [new file with mode: 0644]
tests/integration/ssh.cfg.j2 [new file with mode: 0644]
tests/integration/ssh.cfg.sample [new file with mode: 0644]

diff --git a/tests/integration/hosts b/tests/integration/hosts
deleted file mode 100644 (file)
index 9b91eea..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[fuel-master]
-fuel-master
-
-[local]
-localhost   ansible_connection=local
-
diff --git a/tests/integration/hosts.j2 b/tests/integration/hosts.j2
new file mode 100644 (file)
index 0000000..868a4e5
--- /dev/null
@@ -0,0 +1,21 @@
+[fuel-master]
+fuel-master
+
+[local]
+localhost   ansible_connection=local
+
+[fuel-groups:children]
+{% for group in hosts|sort %}
+{{ group }}
+{% endfor %}
+
+[fuel-groups:vars]
+ansible_ssh_common_args=-F ./ssh.cfg
+
+{% for group in hosts|sort %}
+[{{ group }}]
+{% for host in hosts[group]|sort %}
+{{ host }}
+{% endfor %}
+
+{% endfor %}
diff --git a/tests/integration/hosts.sample b/tests/integration/hosts.sample
new file mode 100644 (file)
index 0000000..e37d38e
--- /dev/null
@@ -0,0 +1,83 @@
+[fuel-master]
+fuel-master
+
+[local]
+localhost   ansible_connection=local
+
+[fuel-groups:children]
+ceph-osd
+cluster-1
+compute
+controller
+hw-zte-servers
+mongo
+node-1
+node-2
+node-3
+node-4
+node-5
+node-6
+node-7
+
+[fuel-groups:vars]
+ansible_ssh_common_args=-F ./ssh.cfg
+
+[ceph-osd]
+node-2
+node-4
+node-6
+node-7
+
+[cluster-1]
+node-1
+node-2
+node-3
+node-4
+node-5
+node-6
+node-7
+
+[compute]
+node-2
+node-4
+node-6
+node-7
+
+[controller]
+node-1
+node-3
+node-5
+
+[hw-zte-servers]
+node-1
+node-2
+node-3
+node-4
+node-5
+node-6
+node-7
+
+[mongo]
+node-1
+
+[node-1]
+node-1
+
+[node-2]
+node-2
+
+[node-3]
+node-3
+
+[node-4]
+node-4
+
+[node-5]
+node-5
+
+[node-6]
+node-6
+
+[node-7]
+node-7
+
similarity index 84%
rename from tests/integration/compute.yaml
rename to tests/integration/run.yaml
index 87553fd..7eb141d 100644 (file)
@@ -8,20 +8,6 @@
 ##############################################################################
 
 ---
-# Prepare connection to SUT (System Under Test)
-- hosts: fuel-master
-  gather_facts: no
-  tasks:
-  - name: collect facts of fuel hosts
-    fuel:
-  - name: add compute node to ansible inventory
-    add_host:
-      name: "{{ hosts_meta[item]['ip'] }}"
-      groups: compute
-      ansible_user: root
-      ansible_ssh_common_args: '-o StrictHostKeyChecking=No -o ProxyJump=fuel-master'
-    with_items: "{{ hosts.compute }}"
-
 # Execute compute benchmark plan and collect data
 # - system information
 # - test condition
diff --git a/tests/integration/setup.yaml b/tests/integration/setup.yaml
new file mode 100644 (file)
index 0000000..784d6cc
--- /dev/null
@@ -0,0 +1,21 @@
+##############################################################################
+# Copyright (c) 2017 ZTE Corporation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Prepare connection to SUT (System Under Test)
+- hosts: fuel-master
+  gather_facts: no
+  tasks:
+  - name: collect facts of fuel hosts
+    fuel:
+  - name: update inventory file
+    template: src=./hosts.j2 dest=./hosts
+    delegate_to: localhost
+  - name: update ssh.cfg file
+    template: src=./ssh.cfg.j2 dest=./ssh.cfg
+    delegate_to: localhost
diff --git a/tests/integration/ssh.cfg.j2 b/tests/integration/ssh.cfg.j2
new file mode 100644 (file)
index 0000000..2fe049e
--- /dev/null
@@ -0,0 +1,14 @@
+# Connect to target node through jump host
+#
+# OpenSSH 7.3:
+#   ProxyJump jumphost
+# before OpenSSH 7.3
+#   ProxyCommand ssh -o 'ForwardAgent yes' jumphost 'ssh-add && nc %h %p'
+
+{% for (name, host) in hosts_meta.items() %}
+Host {{ name }}
+  HostName {{ host.ansible_ssh_host }}
+  User root
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+
+{% endfor %}
diff --git a/tests/integration/ssh.cfg.sample b/tests/integration/ssh.cfg.sample
new file mode 100644 (file)
index 0000000..efa45ab
--- /dev/null
@@ -0,0 +1,56 @@
+Host node-5
+  HostName 10.20.5.12
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+
+Host node-4
+  HostName 10.20.5.14
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+
+Host node-7
+  HostName 10.20.5.15
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+
+Host node-6
+  HostName 10.20.5.16
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+
+Host node-1
+  HostName 10.20.5.10
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+
+Host node-3
+  HostName 10.20.5.11
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+
+Host node-2
+  HostName 10.20.5.13
+  User root
+  # Use `ProxyCommand` for OpenSSH before 7.3
+  ProxyCommand ssh -o 'ForwardAgent yes' fuel-master 'ssh-add && nc %h %p'
+  # `ProxyJump` is available since OpenSSH 7.3
+  # ProxyJump fuel-master
+