Packer get instance_id in a variable

290 views
Skip to first unread message

Svetlio Shushkov

unread,
Jun 8, 2021, 3:04:14 PM6/8/21
to Packer
Hi All,

I am using oracle-oci builder to create the instance and the image afterwards, but in between these two, I need to apply some configuration using ansible.

I would like to let ansible know the instance that it needs to do this to (local ansible), since I need to attach a block volume to it.

Is there a normal way of obtaining this information from either packer or the builder or any other way, so that I can configure the instance?

Thanks

Wilken Rivera

unread,
Jun 9, 2021, 10:21:35 AM6/9/21
to packe...@googlegroups.com
Hi there, 

Packer does provide a way for providing the instance id to provisioners using build variables. However, these build variables do vary by builder type as it is on the builder to set the value. If the oracle-oci builder offers access to the instance id you can reference it via ${build.ID} for HCL2 templates or {{build `ID`}} in JSON templates. 

Is the instance ID the information you are looking for?


There are additional build variables such as HOST, Password, etc.
I would suggest giving the build variable a try and seeing if it contains the information you are looking for.


--
Wilken Rivera <d...@wilkenrivera.com>

--
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.
 
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 packer-tool...@googlegroups.com.

Svetlio Shushkov

unread,
Jun 24, 2021, 9:04:22 AM6/24/21
to Packer
Hey guys,

Thanks for letting me know of this, I wasn't paying attention to those variables.
Thanks again :)

Reply all
Reply to author
Forward
0 new messages