Usage of isotime in Naming custom Images for Oracle Cloud Infrastructure

33 views
Skip to first unread message

Anil Shenoy

unread,
Feb 21, 2020, 9:55:07 PM2/21/20
to Packer
Hi All,

Can you please suggest what is the best way to use isotime and rename a custom image in OCI?

I have used the below and it worked fine.

"my.timevar": "WinImage-{{isotime \"2006-01-02\"}}",

But it not behaving vague when i use

"my.timevar": "WinImage-{{isotime \"2006-01-02 15-04-05\"}}",

"my.timevar": "WinImage-{{isotime 2 Jan 2006 15:04:05"}}"

"my.timevar": "WinImage-{{isotime \"02-Jan-06 03\_04\_05\"}}

and many other ways.

Can you please suggest an accurate one that will display the date and time both.

Best regards,

Alvaro Miranda Aguilera

unread,
Feb 26, 2020, 2:10:15 PM2/26/20
to packe...@googlegroups.com
Hello

Have your tried like the documentation?

{{isotime \"2006-01-02 03:04:05\"}}"

--
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/mitchellh/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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/847b01c8-d625-47f0-8736-37e1f2f4cbbc%40googlegroups.com.


--
Alvaro

Anil_ Shenoy

unread,
Feb 28, 2020, 2:08:01 PM2/28/20
to packe...@googlegroups.com
Hi,

Thanks, i have used this, but this would not give a time stamp. This time 2006-01-02 03:04:05 (or any time that we mention)  will be associated in image. That's it.

{{isotime \"2006-01-02 03:04:05\"}}"

Megan Marsh

unread,
Feb 28, 2020, 2:16:26 PM2/28/20
to packe...@googlegroups.com
It works for me as documented: 

Template: 


{
"variables":
{
"myvar": "packer-{{isotime \"2006-01-02\"}}",
"myvar2": "packer-{{isotime \"2006-01-02 03-04-05\"}}",
"myvar3": "packer-{{isotime \"2006-01-02 03:04:05\"}}"
},
"builders": [
{
"type": "null",
"communicator": "none"
}
],
"provisioners": [
{
"type": "shell-local",
"inline": ["echo {{ user `myvar`}}",
  "echo {{ user `myvar2`}}",
  "echo {{ user `myvar3`}}"]
}
]
}


Output: 
$ PACKER_LOG=0 packer build isotime_formatting_example.json
null: output will be in this color.

==> null: Running local shell script: /var/folders/8t/0yb5q0_x6mb2jldqq_vjn3lr0000gn/T/packer-shell381620806
    null: packer-2020-02-28
    null: packer-2020-02-28 07-14-11
    null: packer-2020-02-28 07:14:11
Build 'null' finished.

==> Builds finished. The artifacts of successful builds are:
--> null: Did not export anything. This is the null builder

Anil_ Shenoy

unread,
Feb 28, 2020, 5:51:04 PM2/28/20
to packe...@googlegroups.com
Hi,

Thank you very much. Tried and tested successfully. 

"myvar2": "packer-{{isotime \"2006-01-02 03-04-05\"}}"  

Works perfectly fine.

The name of the image observed is formatted as expected:- 

OCI-Image-2020-02-28 09-53-19

Reply all
Reply to author
Forward
0 new messages