| |
@@ -206,11 +206,11 @@
|
| |
return os.path.join(artifacts, path)
|
| |
|
| |
|
| |
- def inv_list(subjects):
|
| |
+ def inv_list(opts):
|
| |
hosts = []
|
| |
variables = {}
|
| |
- for subject in subjects:
|
| |
- host_vars = inv_host(subject)
|
| |
+ for subject in opts.subjects:
|
| |
+ host_vars = inv_host(subject, opts)
|
| |
if host_vars:
|
| |
hosts.append(subject)
|
| |
variables[subject] = host_vars
|
| |
@@ -447,7 +447,7 @@
|
| |
return qemu_proc, port, log_guest
|
| |
|
| |
|
| |
- def inv_host(image):
|
| |
+ def inv_host(image, opts):
|
| |
if not image.endswith((".qcow2", ".qcow2c")):
|
| |
logger.info("Return empty inventory for image: %s.", image)
|
| |
return EMPTY_INVENTORY
|
| |
@@ -489,6 +489,9 @@
|
| |
if proc is None:
|
| |
raise RuntimeError("Could not launch VM for qcow2 image"
|
| |
" '{0}':{1}".format(image, cpe.output))
|
| |
+ ssh_args = "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
| |
+ if opts.extra_ssh_args:
|
| |
+ ssh_args += " " + opts.extra_ssh_args
|
| |
for _ in range(0, 600):
|
| |
try:
|
| |
# The variables
|
| |
@@ -498,7 +501,7 @@
|
| |
"ansible_user": DEF_USER,
|
| |
"ansible_ssh_pass": DEF_PASSWD,
|
| |
"ansible_ssh_private_key_file": identity,
|
| |
- "ansible_ssh_common_args": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
| |
+ "ansible_ssh_common_args": ssh_args,
|
| |
}
|
| |
# Write out a handy inventory file, for our use and for debugging
|
| |
inventory = os.path.join(directory, "inventory")
|
| |
@@ -640,6 +643,7 @@
|
| |
parser = argparse.ArgumentParser(description="Inventory for a QCow2 test image")
|
| |
parser.add_argument("--list", action="store_true", help="Verbose output")
|
| |
parser.add_argument('--host', help="Get host variables")
|
| |
+ parser.add_argument('--extra-ssh-args', default=os.environ.get("TEST_EXTRA_SSH_ARGS"), help="Extra arguments to pass to SSH")
|
| |
parser.add_argument("subjects", nargs="*", default=shlex.split(os.environ.get("TEST_SUBJECTS", "")))
|
| |
opts = parser.parse_args()
|
| |
# Send logs to common logfile for all default provisioners.
|
| |
@@ -660,9 +664,9 @@
|
| |
raise Exception("Fail to find ansible.")
|
| |
logger.info("Path to ansible: %s", ansible_bin)
|
| |
if opts.host:
|
| |
- data = inv_host(opts.host)
|
| |
+ data = inv_host(opts.host, opts)
|
| |
else:
|
| |
- data = inv_list(opts.subjects)
|
| |
+ data = inv_list(opts)
|
| |
# Dump Ansible inventory.
|
| |
sys.stdout.write(json.dumps(data, indent=4, separators=(',', ': ')))
|
| |
|
| |
would not it make sense to pass here just the
opts
asopts.host
is obviously part of theopts
? (unless this is part of some API).