I’m a bit confused about when Ruby gets compiled, how this interacts
with attributes and how to get attribute data that is saved early in
the recipe to be available later in the recipe.
My desired outcome is to have the recipe create a volume from a
snapshot, grab the resulting volume id and insert it into the backup
script so that new backups can snapshot the new volume.
Early in my recipe I have this:
aws_ebs_volume “app_db_volume” do
The aws_ebs_volume resource saves the resulting EBS volume id to node data.
Later on I have - this is where I grab the volume id that was saved
and put it into the snapshot:
template “/usr/local/sbin/app_db_snapshot.sh” do
:directory => “/var/lib/postgresql/8.4/main”,
:description => “Apps Database QA”,
:volume_id => node[:aws][:ebs_volume][:app_db_volume][:volume_id]
I had this running fine in a node that had already successfully
attached to the volume and saved the volume id… When I ran it on a
brand new node I get:
FATAL: NoMethodError: undefined method `’ for nil:NilClass
This happens just as soon as the processing gets to the recipe but
before it does anything at all.
My hyptothesis is that the recipe is being compiled by Ruby and it’s
not finding the node data and thus the error.
So, how do I access node data from earlier in the recipe? Or do I need
to break this code into a separate recipe?
Thanks in advance,