#62 standard-inventory-qcow2: Print out inventory path when debugging
Merged 6 years ago by merlinm. Opened 6 years ago by stefw.
stefw/standard-test-roles print-inventorcy  into  master

@@ -182,17 +182,18 @@ 

                  "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 @@ 

      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):

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.

Tested and works as advertised, so I'm merging.

Something that could be improved, perhaps... When using the generated inventory file, it's very confusing that the playbook output reports hostname localhost regardless if the plays are executing on the executor host or on the target.

Pull-Request has been merged by merlinm

6 years ago
Metadata