Undeffine method replace_only
alanheli92 opened this issue · 12 comments
Hi there. i'm using the replace_or_add resource and i'm getting the bellow error.
NoMethodError�[0m
undefined method `replace_only' for Chef::Resource::ReplaceOrAdd�[0m
Already check the cookbook metadata.rb have the depends to the line cookbook.
is ther a usage doc apart from the resources documentation?
Thanks
Hi there. this the config for replace_or_add resource
replace_or_add 'monitor' do
path '/foo/bar/monitor.xml'
pattern '<enabled>.*</enabled>'
line "<enabled>#{monitor}</enabled>"
replace_only true
notifies :restart, 'service[monitor]', :delayed
end
Is pretty same to the examples that you have.
Linux flavor Amazon linux 2
Are you using the latest version of line? What version of the chef client are you using?
Could you include the chef client log messages for this resource in this ticket?
the line version is 2.9.3 and i'm using chef solo
chef solo, but which version of the chef client? I may need you to zip your cookbook or at least send a copy of the recipe. Whatever you are running into is sort of obscure.
I looked for a way to cause this problem and didn't see one. I'm a little concerned about the characters at the end of the lines you pasted. Please see if your cookbook passes "cookstyle -a" cleanly. If possible please send a stack trace from the error and the actual chef-client run of the resource.
I'm getting similar error, also for line version 2.9.3
:
undefined method `replace_or_add' for cookbook: testcookbook, recipe: default :Chef::Recipe
chef-client 16.2.73. I am using depends 'line'
in my cookbook metadata.rb without specifying version
line is at version 4 something now. You might upgrade and see there is still a problem.
If you would like to pursue it please open a new issue and include a recipe that can be used to recreate the problem.
This turned out to be a chef 16.2 breaking change solved by adding include_recipe 'line'
to my default recipe
@YAMLcase Thank you for the follow up.