From 5bb8fc139481bd6464ab9ec070d24b44bfa41433 Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Oct 25 2021 14:26:19 +0000 Subject: Merge #404 `add support for TEST_SSHD_USEDNS_NO` --- diff --git a/README.md b/README.md index 0c37b8c..5f00184 100644 --- a/README.md +++ b/README.md @@ -208,5 +208,12 @@ all: If the number of hostaliases does not match the number of subjects, you will get an error. +## TEST_SSHD_USEDNS_NO + +Some EL7 systems have `sshd` configured with `UseDNS yes` by default. This will +cause terrible performance with `ssh` and especially with Ansible. You can use +`--sshd-usedns-no` or set `TEST_SSHD_USEDNS_NO=True` to configure the VM to use +`UseDNS no` instead. + [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 77a5758..2120723 100755 --- a/inventory/standard-inventory-qcow2 +++ b/inventory/standard-inventory-qcow2 @@ -65,6 +65,17 @@ AUTH_KEY = ("AAAAB3NzaC1yc2EAAAADAQABAAABAQDUOtNJdBEXyKxBB898rdT54ULjMGuO6v4jLX" DEF_USER = "root" DEF_PASSWD = "foobar" DEF_HOST = "127.0.0.3" +# configure sshd to use UseDNS no to fix broken EL7 systems +BOOTCMD_SSHD_USEDNS_NO = """bootcmd: + - | + if grep -q '^UseDNS' /etc/ssh/sshd_config; then + sed 's/^UseDNS.*$/UseDNS no/' -i /etc/ssh/sshd_config + elif grep -q '^#UseDNS' /etc/ssh/sshd_config; then + sed 's/^#UseDNS.*$/UseDNS no/' -i /etc/ssh/sshd_config + else + echo "UseDNS no" >> /etc/ssh/sshd_config + fi +""" USER_DATA = """#cloud-config users: - default @@ -485,6 +496,8 @@ def inv_host(opts, image, hostalias): userdata = os.path.join(directory, "user-data") with open(userdata, 'w') as f: f.write(USER_DATA) + if opts.sshd_usedns_no: + f.write(BOOTCMD_SSHD_USEDNS_NO) # Create our cloud init so we can log in cloudinit = os.path.join(directory, "cloud-init.iso") subprocess.check_call(["/usr/bin/genisoimage", "-input-charset", "utf-8", @@ -654,6 +667,13 @@ def help_hostalias(): --use-basename, then you do not have to use --hostalias for every subject. """ + +def help_sshd_usedns_no(): + return """On some EL7 systems, sshd uses 'UseDNS yes' by default. This can + create a very bad performance problem with ssh and Ansible. You can use + --sshd-usedns-no to configure the VM to use 'UseDNS no' instead.""" + + def main(): global logger global diagnose @@ -683,6 +703,7 @@ def main(): parser.add_argument('--host', help="Full path to qcow2 disk image") parser.add_argument("--use-basename", default=bool(distutils.util.strtobool(os.environ.get("TEST_USE_BASENAME", "False"))), action="store_true", help=help_hostalias()) parser.add_argument("--hostalias", default=shlex.split(os.environ.get("TEST_HOSTALIASES", "")), action="append", help=help_hostalias()) + parser.add_argument("--sshd-usedns-no", default=bool(distutils.util.strtobool(os.environ.get("TEST_SSHD_USEDNS_NO", "False"))), action="store_true", help=help_sshd_usedns_no()) 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.