should a custom resource (the one introduced in chef 12.5) respect guards
like only_if and not_if?
i tried including a custom resource (defined by me in another cookbook) in
a recipe with a only_if guard, but it seems to be ignored.
should a custom resource (the one introduced in chef 12.5) respect guards
like only_if and not_if?
i tried including a custom resource (defined by me in another cookbook) in
a recipe with a only_if guard, but it seems to be ignored.
They definitely should! Can you please paste the code you’re using?
When I run the following, it seems to work OK:
class X < Chef::Resource
resource_name :x
property :y
action :create do
end
end
x 'a' do
y 5
only_if { y > 10 }
end
When I run chef-apply file.rb, it prints:
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* x[a] action create (skipped due to only_if)
i am getting same result for that example.
i must have done something else wrong then… probably my (unrelated)
mistake.
thanks i found the error i think, it was my mistake.
i am left with one unrelated confusion. if i do what is shown below in my
custom resource action the file resource is completely ignored. it works
fine if i replace the file resource with anything else, like cookbook_file.
whats up with file not working? am i using some other “file” class that is
not what i think it is?
action :create do
file “/tmp/test” do
content "this is a test"
end
end
actually i cannot reproduce that. i believe my mistake was that i also used
a variable called file. so i was trying to do:
file file do
content "this is a test"
end
please disregard!