diff options
author | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2017-04-12 12:14:59 +0800 |
---|---|---|
committer | Yujun Zhang <zhang.yujunz@zte.com.cn> | 2017-04-12 16:09:45 +0800 |
commit | 8ee70654479bff695a6781a9f3eaea9f5eb6b765 (patch) | |
tree | e25f8637aa5a462284521d7efd5d3851b124f971 /tests | |
parent | 984be06d90caa765bf8bc035546f0e33e7784dec (diff) |
Refactoring connection task
- 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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/hosts | 6 | ||||
-rw-r--r-- | tests/integration/hosts.j2 | 21 | ||||
-rw-r--r-- | tests/integration/hosts.sample | 83 | ||||
-rw-r--r-- | tests/integration/run.yaml (renamed from tests/integration/compute.yaml) | 14 | ||||
-rw-r--r-- | tests/integration/setup.yaml | 21 | ||||
-rw-r--r-- | tests/integration/ssh.cfg.j2 | 14 | ||||
-rw-r--r-- | tests/integration/ssh.cfg.sample | 56 |
7 files changed, 195 insertions, 20 deletions
diff --git a/tests/integration/hosts b/tests/integration/hosts deleted file mode 100644 index 9b91eea6..00000000 --- a/tests/integration/hosts +++ /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 index 00000000..868a4e57 --- /dev/null +++ b/tests/integration/hosts.j2 @@ -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 index 00000000..e37d38ec --- /dev/null +++ b/tests/integration/hosts.sample @@ -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 + diff --git a/tests/integration/compute.yaml b/tests/integration/run.yaml index 87553fd7..7eb141d7 100644 --- a/tests/integration/compute.yaml +++ b/tests/integration/run.yaml @@ -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 index 00000000..784d6cc5 --- /dev/null +++ b/tests/integration/setup.yaml @@ -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 index 00000000..2fe049e2 --- /dev/null +++ b/tests/integration/ssh.cfg.j2 @@ -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 index 00000000..efa45ab6 --- /dev/null +++ b/tests/integration/ssh.cfg.sample @@ -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 + |