1

I am using a cookbook_file resource to copy a file to the node. The file contains a variable as
HOST_ADDR='x.x.x.x'

Now, after copying the file to the node, I want to replace value of Host_ADDR from 'x.x.x.x' to #{node['ipaddress']}

StephenKing
  • 36,187
  • 11
  • 83
  • 112
meallhour
  • 13,921
  • 21
  • 60
  • 117

2 Answers2

1

Use the template resource instead and add a variable to the file as follows:

HOST_ADDR='<%= node['ipaddress'] %>'
StephenKing
  • 36,187
  • 11
  • 83
  • 112
0

Chef allows you to do that with Chef::Util::FileEdit see for example How can I change a file with Chef?

Community
  • 1
  • 1
onknows
  • 6,151
  • 12
  • 65
  • 109