Hello all,

I have found a way to get the name of the VM used to build a packer image 
but it feels difficult, like there should be an easier way.  Hoping that 
someone with more Packer experience can show me the error of my ways.

  provisioner "shell-local" {
    environment_vars = ["private_key=${build.SSHPrivateKey}"]
    inline_shebang = "/bin/bash -e"  # use bash so that the <<< works
    inline = [
              "eval `ssh-agent`",
              "ssh-add - <<< $private_key",
              "packer_hostname=`ssh ${build.User}@${build.Host} -o 
StrictHostKeyChecking=no hostname`",
              "echo 'hostname:' $packer_hostname",
              "az vm show --subscription ${var.subscription_id} -g ${var.
packer_rg_name} -n $packer_hostname"
            ]
  }


Regards,
Shane

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/hashicorp/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/afcc6ec1-9b42-497d-af30-acdc4924829en%40googlegroups.com.

Reply via email to