From 4a8b8f47584e2d19e9cf09f3dd945d5e015de467 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Aug 27 2021 18:48:45 +0000 Subject: add support for TEST_EXTRA_SSH_ARGS https://pagure.io/standard-test-roles/issue/400 User can pass in extra SSH arguments to workaround the issue. --- diff --git a/README.md b/README.md index ad87a9f..8d31ec0 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,15 @@ is missing. Let's look at an example: ansible_python_interpreter: "{% if vm_python_interpreter != '' %}{{ vm_python_interpreter }}{% else %}/usr/bin/python2{% endif %}" ``` +## TEST_EXTRA_SSH_ARGS for standard-inventory-qcow2 + +If you are working with very old releases, like EL6, you may have to pass in +additional SSH arguments to allow newer systems to use older cipher suites. +For example: +``` +TEST_EXTRA_SSH_ARGS="-o PubkeyAcceptedKeyTypes=+ssh-rsa" TEST_SUBJECTS=/path/to/el6.qcow2 ... +``` + [1]: https://fedoraproject.org/wiki/CI/Metadata [2]: http://fmf.readthedocs.io/ diff --git a/inventory/standard-inventory-qcow2 b/inventory/standard-inventory-qcow2 index f401539..ac55dd6 100755 --- a/inventory/standard-inventory-qcow2 +++ b/inventory/standard-inventory-qcow2 @@ -206,11 +206,11 @@ def get_artifact_path(path=""): 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 @@ def start_qemu(image, cloudinit, portrange=(2222, 5555)): 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 @@ def inv_host(image): 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 @@ def inv_host(image): "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 @@ def main(argv): 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 @@ def main(argv): 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=(',', ': ')))