Reputation: 81
I am new to chef, I am trying to replace a specific variable in a file. While running a container a file is generated, I've to replace a value in this by a value I wanted using chef. Leave the container part aside. Is this possible to replace specific variables.
Thanks.
Upvotes: 0
Views: 272
Reputation: 15784
Usually you should not modify a file unless the file has really specific part you can't predict/manage yourself. If you can enforce/know any variable part you should use a template and render the whole file.
On last resort, there's the FileEdit Class you can use to change lines in a file (again this is with high risks).
More details here.
On last if you really need to do this there's Sean O'Meara cookbook line which does part of the job, ensuring idempotency of the modifications needed.
Upvotes: 1