[chef] Re: chef-solo - expand run_list?


Chronological Thread 
  • From: Ranjib Dey < >
  • To: " " < >
  • Subject: [chef] Re: chef-solo - expand run_list?
  • Date: Tue, 29 Sep 2015 08:49:14 -0700

what are you trying to do? expand is used for runlist expansion and triggered way before compilation phase invoked, its somewhat internal API, and invoking it inside a ruby_block resource feels very strange. we might be able to help you  better if you instead tell us what you ware trying to achieve :-/

On Tue, Sep 29, 2015 at 6:50 AM, Alexander Skwar < " target="_blank"> > wrote:
Hello

Using chef-solo and Chef 11.8.2, how do I use "expand" correctly?

I'd like to run certain recipes only then, if a precondition outside of chef is met (if the system has been enrolled in IPA, which I don't do with chef). For this, I've got the following recipe[ew::ipa-check]:


ruby_block 'Entferne -ipa recipes von der run list, falls IPA noch NICHT initialisiert wurde' do
    block do
        node.run_list.expand(node.chef_environment, "disk").run_list_items.each do |run_list_item|
            node.run_list.remove(run_list_item) if run_list_item.end_with? "-ipa"
        end # of node.run_list.expand(node.chef_environment, "disk").run_list_items.each do |run_list_item|
    end
    not_if "getent passwd _ipa-check"
end # of ruby_block 'Entferne -ipa recipes von der run list, falls IPA noch NICHT initialisiert wurde' do


This doesn't work, though… For some reason, "node.run_list.expand(node.chef_environment, "disk").run_list_items" is "empty" - the ".each" block isn't run.

node.run_list returns/contains (per node.run_list.to_s): role[ew-ubuntu], role[mgmt], role[hardened]

I also tried using node.expand!, but this didn't work either… :(

node_expanded = node.expand!("disk")
File.open("/tmp/debug.txt", 'a') { |file| file.write("node_expanded.run_list:\n" + node_expanded.run_list_items.to_s + "\n"); }

And /tmp/debug.txt contains:

node_expanded.run_list:
[]



Why is that? Am I doing it wrong again?

Thanks,
Alexander
 




Archive powered by MHonArc 2.6.16.

§