I have following chef recipe and I don't want to run template resource when it gets converged under chef solo. It does not seem to obey the not_if while running kitchen converge. It still tries to connect the chef server. Please help.
Recipe,
template '/etc/hosts' do
not_if Chef::Config[:solo]
source 'hosts.erb'
mode '0644'
owner 'root'
group 'root'
variables({
:nodes => search(:node, 'ipaddress:*')
})
end
Template,
...
<% @nodes.each do |n| -%>
<% if (n['fqdn'] && n['ipaddress']) -%>
<%= n['ipaddress'] %> <%= n['fqdn'] %>
<% end -%>
<% end -%>
...
.kitchen.yml
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: centos-6.7
...