[chef] chef-solo - expand run_list?


Chronological Thread 
  • From: Alexander Skwar < >
  • To:
  • Subject: [chef] chef-solo - expand run_list?
  • Date: Tue, 29 Sep 2015 15:50:44 +0200

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.

§