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.
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 :-/
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.
Mid chef run run_list changes don't affect the current run.
I think you're looking at this backwards anyway, why not just wrap your IPA
recipe in an if statement (or the include statement for it).
In any case, looking at the run_list expansion code it seems that the items
go in the recipes attribute not run_list_items after calling expand. I
don't see that expand takes any parameters either, although (old)
references to it show examples of calling it with parameters.
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 :-/
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.