[chef] Re: Re: AWS cookbook and the run list


Chronological Thread 
  • From: Greg Barker < >
  • To: " " < >
  • Subject: [chef] Re: Re: AWS cookbook and the run list
  • Date: Fri, 23 Jan 2015 15:50:09 -0800

Should I be relying on the node['cloud']['provider'] instead?

On Wed, Jan 21, 2015 at 7:07 PM, Greg Barker < " target="_blank"> > wrote:
So I added this to my metadata.rb:

depends 'aws'

Added this to my run_list:

    "recipe[aws]",
    "recipe[aws::ec2_hints]",

Added this to my recipe:

if node["ec2"]
  include_recipe "mycookbook::ec2_specific_thing"
end

Works great when I ran it on an EC2 instance. But when I tried a `vagrant up` for a local VM, it hits an error in my ec2_specific_thing recipe. I thought it wasn't going to be executed at all though. Any ideas?

Thanks!
Greg

On Wed, Jan 14, 2015 at 12:03 PM, Greg Barker < " target="_blank"> > wrote:
Awesome!! Thank you!

On Wed, Jan 14, 2015 at 11:54 AM, Noah Kantrowitz < " target="_blank"> > wrote:

On Jan 14, 2015, at 11:47 AM, Greg Barker < " target="_blank"> > wrote:

> I want to use the AWS cookbook to attach EBS volumes. I wasn't sure what the best way to ensure that it only happens when the node is actually an EC2 instance, and not a local Vagrant VM. Separate roles? Separate environments and use env_run_lists? Is there something like if node['is_ec2']?

Yep, you can do this:

if node['ec2']
  include_recipe 'myebsstuff'
end

--Noah






Archive powered by MHonArc 2.6.16.

§