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


Chronological Thread 
  • From: Greg Barker < >
  • To: " " < >
  • Subject: [chef] Re: Re: Re: Re: Re: Re: AWS cookbook and the run list
  • Date: Mon, 26 Jan 2015 17:47:14 -0800

I was hoping to avoid adding complexity to the run list by creating a new environment for EC2 and having to specify the env_run_lists in my base role. If I'm going down that route I would probably just put mycookbook::ec2_specific_
thing on the run_list there, which negates the necessity for using if node["ec2"].

It seems like a much simpler way to solve it would be something like:
if !node["ec2"].empty?
  include_recipe "mycookbook::ec2_specific_thing"
end
Or maybe relying on another attribute like node['cloud']['provider']?

Or am I crazy for trying to avoid env_run_lists here?

Greg

On Sat, Jan 24, 2015 at 9:46 AM, Julian C. Dunn < " target="_blank"> > wrote:
Ah yes. I missed the first part of Greg's email that stated that his
run_list contains recipe[aws::ec2_hints]. So... maybe not a good thing
to do when running under Vagrant :-)

- Julian

On Fri, Jan 23, 2015 at 7:29 PM, Daniel Condomitti
< "> > wrote:
> Julian,
>
> That’s the expected behavior, right? aws::ec2_hints adds the ec2 hints file
> for ohai which causes the node to be recognized as EC2 even if it isn’t. It
> doesn’t have any normal attributes populated but the node[‘ec2’] key exists.
>
> This is a CentOS 6.5 node running in VirtualBox
>
> # chef-shell -z
> ...
> chef > File.exists?('/etc/chef/ohai/hints/ec2.json')
>  => false
> chef > node['ec2']
>  => nil
> chef > exit
>
> # mkdir -p /etc/chef/ohai/hints
> # touch ohai/hints/ec2.json
> # chef-shell -z
>
> ....
> chef > File.exists?('/etc/chef/ohai/hints/ec2.json')
>  => true
> chef > node['ec2']
>  => #<Chef::Node::Attribute @normal={...}, @current_normal=nil,
> @default={...}, @current_default=nil, @override={...},
> @current_override=nil, @automatic={...}, @current_automatic={},
> @current_nesting_level=["ec2"], @auto_vivifiy_on_read=false,
> @set_unless_value_present=false, @set_type=nil, @has_been_read=false>
>
>
> On Friday, January 23, 2015 at 7:11 PM, Julian C. Dunn wrote:
>
> On Wed, Jan 21, 2015 at 10:07 PM, Greg Barker < "> > 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?
>
>
> That shouldn't happen. Can you paste the error?
>
> - Julian
>
>



--
[ Julian C. Dunn < "> >          * Sorry, I'm    ]
[ WWW: http://www.aquezada.com/staff/julian    * only Web 1.0  ]
[ gopher://sdf.org/1/users/keymaker/           * compliant!    ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9       ]




Archive powered by MHonArc 2.6.16.

§