Thanks. Putting the code inside a ruby_block fixes that problem, but raises another. I'm trying to loop through the input file of IP addresses and create a firewalld rich rule for each address with the firewalld_rich_rule resource from the firewalld cookbook.
But when that resource is called within the ruby_block, it results in
NoMethodError
-------------
undefined method `firewalld_rich_rule' for Chef::Resource::RubyBlock
I've tried calling the firewalld cookbook with include_recipe firewalld, without success.
Is there a way to load a resource inside ruby_block, or another approach to solving the original problem of the file getting created at the end of the run instead of at the beginning?
Well, one way you could do that is to put the recipe as part of a user-written resource, and turn on unified_mode. That way, the code in there (and anything that uses it) will execute in the order supplied, and you won't need the ruby_block.