From 8507da6697881739d5e9c17480426d02a69c4939 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sep 22 2017 11:58:05 +0000 Subject: standard-inventory-qcow2: Print out inventory path when debugging When TEST_DEBUG=1 is enabled have standard-inventory-qcow2 print out a valid Ansible inventory file. This allows the developer of tests to rapidly iterate against an Atomic Host that is already running by an eansier invocation. --- diff --git a/inventory/standard-inventory-qcow2 b/inventory/standard-inventory-qcow2 index 112dbca..24978dc 100755 --- a/inventory/standard-inventory-qcow2 +++ b/inventory/standard-inventory-qcow2 @@ -182,17 +182,18 @@ def host(image): "ansible_ssh_common_args": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" } - # wait for ssh to come up + # Write out a handy inventory file, for our use and for debugging args = " ".join([ "{0}='{1}'".format(*item) for item in variables.items() ]) inventory = os.path.join(directory, "inventory") with open(inventory, "w") as f: - f.write("{0} {1}\n".format(image, args)) + f.write("[subjects]\nlocalhost {1}\n".format(image, args)) + # Wait for ssh to come up ping = [ "/usr/bin/ansible", "--inventory", inventory, - image, + "localhost", "--module-name", "raw", "--args", @@ -242,6 +243,7 @@ def host(image): if diagnose: sys.stderr.write("\n") sys.stderr.write("DIAGNOSE: ssh -p {0} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@{1} # password: {2}\n".format(port, "127.0.0.3", "foobar")) + sys.stderr.write("DIAGNOSE: export ANSIBLE_INVENTORY={0}\n".format(inventory)) sys.stderr.write("DIAGNOSE: kill {0} # when finished\n".format(os.getpid())) def _signal_handler(*args):