如何更改使用 cookbook_file 资源复制的文件中的变量值?

How to change value of variable within a file that is copied using cookbook_file resource?

我正在使用 cookbook_file 资源将文件复制到节点。该文件包含一个变量 as
HOST_ADDR='x.x.x.x'

现在,将文件复制到节点后,我想将 Host_ADDR 的值从 'x.x.x.x' 替换为 #{node['ipaddress']}

改为使用 template 资源并向文件添加一个变量,如下所示:

HOST_ADDR='<%= node['ipaddress'] %>'

Chef 允许您使用 Chef::Util::FileEdit 做到这一点,例如 How can I change a file with Chef?