[chef] Re: Re: Changing the order of 'run_list'


Chronological Thread 
  • From: Tiago Cruz < >
  • To: " " < >
  • Subject: [chef] Re: Re: Changing the order of 'run_list'
  • Date: Fri, 5 Jun 2015 15:09:36 -0300

Hello Daniel, thanks for your time!

Could you please help with some example? I think that I don't get yet :(

- Try 1:

node.run_list.add("role[base]", --before, "role[web]") 

[2015-06-05T17:51:29+00:00] ERROR: ruby_block[Add base before web] (test::web line 7) had an error: NoMethodError: undefined method `before' for Chef::Resource::RubyBlock

- Try 2:

node.run_list.add("role[base]", before, "role[web]") 

[2015-06-05T17:53:01+00:00] ERROR: ruby_block[Add base before web] (test::web line 7) had an error: NoMethodError: undefined method `before' for Chef::Resource::RubyBlock

- Try 3:

node.run_list.add("role[base]", "before", "role[web]") 

[2015-06-05T17:47:04+00:00] ERROR: ruby_block[Add base before web] (test::web line 7) had an error: ArgumentError: wrong number of arguments (3 for 1)

Thanks!

On Fri, Jun 5, 2015 at 12:19 PM, Daniel DeLeo < " target="_blank"> > wrote:


On Friday, June 5, 2015 at 8:01 AM, Tiago Cruz wrote:

> Ohai!
>
> To add one recipe before other, I can use:
>
> knife node run_list add lasvegas1 'role[base]' --before 'role[web]'
>
> But I can't do this using recipe:
>
> if not node.run_list.roles.include?('base')
> ruby_block "Add base role before web" do
> block { node.run_list.add("role[base]").before("role[web]") }
> end
> end
>
> How can I do this?
>
> Thanks!
>
> --
> -- Tiago Cruz

The run list is just a ruby array, use ruby’s Array methods for this.

http://ruby-doc.org/core-2.2.0/Array.html#method-i-insert

--
Daniel DeLeo






--
-- Tiago Cruz




Archive powered by MHonArc 2.6.16.

§