I am looking to test a recipe using Vagrant. In one of my recipe I have this line in a run block:
cookbook_file ‘/etc/some_conf_file’ do
source 'conf_file’
owner 'root’
group 'root’
mode '440’
action :create
only_if "node.role?(‘some_client’)"
end
And in my Vagrant file, I add the role as follows:
chef.roles_path = ['/Users/tonywu/Documents/git_root/chef_cookbooks/roles']
chef.add_role("some_client")
Vagrant picks up the run list defined in the role file, but the actual role doesn’t seem to be defined on the vagrant instance:
chef (12.17.44)> node[‘roles’]
=> []
And because of this the only_if condition of the run block isn’t being considered. Is this a limitation of Chef solo, or am I missing something obvious?
Thanks very much.