- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Delaying evaluation in chef provisioning script to pass dynamically assigned IDs
- Date: Fri, 30 Jan 2015 09:53:02 -0800
On Thursday, January 29, 2015 at 6:41 PM, Christine Draper wrote:
>
Apologies for more than one question in one day but I am really stuck on
>
this one.
>
>
I am working on a chef provisioning script that sets up a subnet and then
>
creates a machine in it.
>
>
I want to do something like this to tell chef to provision the machine in
>
the subnet it has just created. I need to delay querying the data bag until
>
converge time, but I can't figure out how to do it.
>
>
with_machine_options :bootstrap_options => {
>
:key_name => 'xxxx',
>
:instance_type => 't1.micro',
>
:subnet => data_bag_item("aws_subnet", "subnet-a")["subnet_id"],
>
:associate_public_ip_address => true
>
}
>
>
I have a similar problem later when I need to pass an IP address from one
>
machine to another, and I need the 'attribute' to be evaluated at converge
>
time:
>
>
machine 'db' do
>
run_list ['apt','automateinsights::db']
>
end
>
>
machine 'appserver' do
>
run_list ['automateinsights::deploy_from_package']
>
attribute ['automateinsights', 'envconfig', 'db_location'], need db
>
ipaddress here
>
end
>
>
Regards,
>
Christine
I’m not familiar enough with chef-provisioning to tell you how to get the db
IP address from EC2 (you could use search if you’re using a Chef Server). For
lazy evaluation of resource attributes, though, you can use the lazy
evaluation feature:
http://docs.chef.io/resource_common.html#lazy-attribute-evaluation
HTH,
--
Daniel DeLeo
Archive powered by MHonArc 2.6.16.