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
On Fri, Feb 28, 2020 at 11:08 AM Anil_ Shenoy <[email protected]>
wrote:
> 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\"}}"
>
>
> On Thu, Feb 27, 2020 at 12:40 AM Alvaro Miranda Aguilera <
> [email protected]> wrote:
>
>> Hello
>>
>> Have your tried like the documentation?
>>
>> {{isotime \"2006-01-02 03:04:05\"}}"
>>
>>
>> On Fri, Feb 21, 2020 at 9:55 PM Anil Shenoy <[email protected]>
>> wrote:
>>
>>> 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,
>>>
>>> --
>>> 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 [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/packer-tool/847b01c8-d625-47f0-8736-37e1f2f4cbbc%40googlegroups.com
>>> <https://groups.google.com/d/msgid/packer-tool/847b01c8-d625-47f0-8736-37e1f2f4cbbc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>
>>
>> --
>> Alvaro
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/packer-tool/CAHqq0ex7XMW8m5YRoheuRmqwk3fwJ4ZYp0U%3D6XDkqyPxuAp8kQ%40mail.gmail.com
>> <https://groups.google.com/d/msgid/packer-tool/CAHqq0ex7XMW8m5YRoheuRmqwk3fwJ4ZYp0U%3D6XDkqyPxuAp8kQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/CAK%2BF8Jxdi4Ji6%3DWZiaDndha6RWHXDnODgWLXfOPGJDYrR9j2Qg%40mail.gmail.com
> <https://groups.google.com/d/msgid/packer-tool/CAK%2BF8Jxdi4Ji6%3DWZiaDndha6RWHXDnODgWLXfOPGJDYrR9j2Qg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/CAGPV1uqSn%3D23G72h6QiJJSu8eyX90Bt9XB0122vJPAkTKHiQ9Q%40mail.gmail.com.