Daniel,
Thanks, I tried again for the machine resource I think this works:
machine 'appserver' do
run_list ['automateinsights::deploy_from_package']
attribute ['automateinsights', 'envconfig', 'db_location'], lazy {
search(:node, "name:db").first['ipaddress'] }
end
However, I really can't figure out a way to do anything to delay the
with_machine_options. I guess its not the same resource/attribute pattern.
I keep getting:
[2015-01-30T12:07:47-06:00] ERROR: No resource or method named lazy' for
Chef::Recipe "/home/christine/test/provision/provision_network_aws.rb"'
Here's some of the things I've tried.
with_machine_options :bootstrap_options => {
:key_name => 'test1_aws',
:instance_type => 't1.micro',
:subnet => lazy { data_bag_item("aws_subnet",
"provisioning-vpc-subnet-a")["subnet_id"] },
:associate_public_ip_address => true
}
and:
with_machine_options :bootstrap_options => lazy { {
:key_name => 'test1_aws',
:instance_type => 't1.micro',
:subnet => data_bag_item("aws_subnet",
"provisioning-vpc-subnet-a")["subnet_id"],
:associate_public_ip_address => true
}}
On Fri, Jan 30, 2015 at 11:53 AM, Daniel DeLeo dan@kallistec.com wrote:
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:
Common Resource Functionality
HTH,
--
Daniel DeLeo