I am attempting to to use lazy evaluation, and don’t think I quite understand how it works. I have a ruby_block that I use to set an attribute as so:
ruby_block 'get-sssd-dc' do block do Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) adcli_info = "adcli info #{node['domain']} | grep 'domain-controller =' | awk '{print $3}'" adcli_dc_out = shell_out(adcli_info) adcli_dc = adcli_dc_out.stdout node.set['node-info']['sssd']['dc'] = adcli_dc end action :create end
I then want to use a lazy evaluation in a template erb file:
ad_server = <%= lazy {node['node-info']['sssd']['dc']} %>
This is the value that is left when it converges:
ad_server = #<Enumerator::Lazy:0x00000007a61bc8>
So the question is, is it possible to do what I am trying to do, or am I not understanding how lazy evaluation works? Thanks!