I\'m using chef-cookbook-hostname cookbook to setup node\'s hostname. I don\'t want my hostname to be hard coded in the attribute file (default[\'set_fqdn\']).
In
The source of the problem here is that you are setting the variable fqdn inside the scope of a ruby_block and are attempting to make reference to that variable at the compilation phase. The ruby_block resources allows the ability to run ruby code during the convergence phase.
Given that you appear to be using the fqdn to setup the resource set, it looks as though you can remove the ruby block from around the ruby code. e.g.
fqdn = // logic to get fqdn
file '/tmp/file' do
content "fqdn=#{fqdn}"
end