Reputation: 391
I'm trying to unwind a part of a chef recipe from an upstream cookbook (ceph) in my wrapper cookbook recipe. In brief summary, the ceph user pool create block is being executed too early in the deployment, before certain required services are up and running. I'm moving it out into a new wrapper recipe which will be executed further down the runlist, when the services are running.
To this end, I'm trying to rewind the below block from the ceph::mon upstream recipe and then execute it at a later point in my new wrapper recipe. My code is currently as follows:
include_recipe 'workday::chef-client'
require 'chef/rewind'
include_recipe 'ceph::mon'
if node['ceph']['user_pools']
# Create user-defined pools
node['ceph']['user_pools'].each do |pool|
ceph_pool pool['name'] do
unwind "pool"
pg_num pool['pg_num']
create_options pool['create_options'] if pool['create_options']
end
end
end
The error output from chef-client:
NoMethodError
-------------
undefined method `unwind' for Chef::Resource::CephPool
I've attempted various unwind statements: e.g.
unwind "ceph_pool pool['name']"
unwind "pool['name']"
I have previously used unwind/rewind on resources (e.g. "execute x") but I am not sure how to correctly unwind this. I've read the limited docs that are available from chef-rewind, but I cannot find a solution for this.
Upvotes: 1
Views: 182
Reputation: 391
I've resolved this issue and will share my solution in case someone runs into a similar problem in future. The correct working solution is as follows:
if node['ceph']['user_pools']
# Create user-defined pools
node['ceph']['user_pools'].each do |pool|
# unwind user-defined pools
unwind "ceph_pool[#{pool['name']}]"
end
end
It failed originally because I didn't interpolate the unwind attribute correctly:
i.e. I had incorrectly used unwind "ceph_pool pool['name']"
instead of the correctly interpolated form: unwind "ceph_pool[#{pool['name']}]"
I hope this answer is of help to anyone else who may run into a similar issue.
Upvotes: 1