After playing with it for a little bit I found the only way to do it is using Chef Libraries:
http://stackoverflow.com/questions/15595144/dry-within-a-chef-recipe
You can't just define a method inside a recipe and use it, a module with a static method must be defined.
Since it's static, the call to that function will look something like this

`SolrHelper.run_code_and_restart_jetty(code, self)`

I think I'd rather stay with a code that isn't very DRY than that kind of method.
Any ideas?