engineyard / engineyard/ey-cloud-recipes

resque / resque-scheduler recipes "install resque gem" check not_if always return true, fail to execute the command

Open
#150 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
977
Forks
283
PR merge metrics
No merged PRs in 30d

Description

[cookbooks/resque/recipes/default.rb:9](https://github.com/engineyard/ey-cloud-recipes/blob/master/cookbooks/resque/recipes/default.rb#L9)

``` ruby
not_if { "gem list | grep resque" }
```

[cookbooks/resque-scheduler/recipes/default.rb:8](https://github.com/engineyard/ey-cloud-recipes/blob/master/cookbooks/resque-scheduler/recipes/default.rb#L8)

``` ruby
not_if { "gem list | grep resque" }
```

I find the above 2 lines will always return true.

According to http://docs.opscode.com/resource_common.html#guards
- A string is executed as a shell command. If the command returns 0, the guard is applied. If the command returns any other value, then the guard is not applied.
- A block is executed as Ruby code that must return either true or false. If the block returns true, the the guard is applied. If the block returns false, the guard is not applied.

I guess it is because "{}" interpret as a Ruby code block in chef. The "gem list | grep resque" will become string inside the {}, thus it will always return true.

The fix should be remove the {} block.
i.e.
~~not_if { "gem list | grep resque" }~~

``` ruby
not_if "gem list | grep resque"
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.