Execute guards not working


#1

Hi All,
I have below code. even though my service name does not exist, it still skipping the execute command.

execute ‘test’ do
command "echo hi"
not_if { ‘sc query “asdfiusadf”’ }
end


#2

This is because the guard format is incorrect:

# if a string is passed, then it's just a shell command
not_if "sc query 'asdfiusadf'"
# if a Ruby block is passed, it must eval truthy
not_if { true }

Details are here


#3

Thanks @cheeseplus