While implementing a templated config file using chef 11.x I'd like to insert the current date/time into the file whenever it is updated.
For example:
# Created By : core::time-settings
# On : <%= Time.now %>
Obviously this evaluates on each recipe run and constantly updates the target file even when the other attributes are OK - which is not desired.
Therefore is anyone aware of a solution? I'm not aware of any built-in logic within Chef to achieve this and I don't know of a built-in chef variable that I could evaluate within a ruby block that would only be true if the other attributes are out of compliance (as that would provide a potential workaround).
I know that I could run an execute type operation which only gets run after the template resource has been fired, and it expands a variable in the file to achieve this, but I don't like the concept or idea of doing that.
Thanks,