- From: Douglas Garstang <
>
- To:
- Subject: [chef] Chef-Metal/Provisioning input from multiple json files?
- Date: Thu, 6 Nov 2014 11:08:08 -0800
I was trying to use chef-metal (now called chef provisioning I guess) to deploy and destroy instances from a single rb file for multiple environments. I can pass in the environmental data with a json file, but the action, ie whether to start or stop the instance doesn't belong in the environment json file and it seems that I can't pass two json files with -j to the chef-client.
Eg, my recipe looks like this. There's a case statement that starts or stops the instance based on the value of node['action']. I need to work out how to get the node['action'] input into the file from somewhere... where?
#require 'chef_provisioning_fog'
require 'chef/provisioning/fog_driver'
require 'chef/config'
with_chef_server "#{node['chef_server_url']}", {
:client_name => Chef::Config[:node_name],
:signing_key_filename => Chef::Config[:client_key]
}
case node['action']
when 'create'
machine_batch do
machine "test01.#{node['env']}.slicetest.com" do
chef_environment "#{node['env']}"
role 'role-default'
converge true
machine_options :bootstrap_options => {
:flavor_id => 'm1.large',
:key_name => 'test-ec2-default-v2',
:groups => ['slice-default'],
:image_id => 'ami-226fd44a',
:tags => {"env" => "#{node['env']}", 'role' => 'default' },
:iam_instance_profile_name => 'instance-config',
:availability_zone => "us-east-1a",
:block_device_mapping => [
{ 'DeviceName' => '/dev/sdb', 'VirtualName' => 'ephemeral0' },
{ 'DeviceName' => '/dev/sdc', 'VirtualName' => 'ephemeral1' }
]
},
:ssh_username => 'ec2-user',
:use_private_ip_for_ssh => true
end
end
when 'destroy'
machine "test01.#{node['env']}.slicetest.com" do
action :destroy
end
else
raise "Error"
end
Doug
- [chef] Chef-Metal/Provisioning input from multiple json files?, Douglas Garstang, 11/06/2014
Archive powered by MHonArc 2.6.16.