I am trying to add something to the hostfile of my node through the chef cookbook and my node is a
I am using the following cookbook
hostsfile_entry ‘184.108.40.206’ do
hostname ' www.example.com’
But when I upload this cookbook and run chef-client on my Windows node it says " No such file or directory @ rb_sysopen - /etc/hosts". Is it because this cookbook is only for linux machine and not for Windows.
Have you defined the path attribute for your windows nodes? The default is nil, and my guess (without searching the full code) is that if the attribute is nil that the recipe will look at /etc/hosts.
Which hosts file cookbook are you using? There are 3 listed on the supermarket
If using the customink-webops cookbook, it requires that you set an attribute
default['hostsfile']['path'] = nil
This file has been truncated.
# Author:: Seth Vargo <email@example.com>
# Cookbook:: hostsfile
# Attribute:: default
# Copyright:: 2012-2013, Seth Vargo
# Copyright:: 2012, CustomInk, LCC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
I have been using the hostfile cookbook provided by sethvargo. I like how
it provides a lightweight wrapper.
I am using this cookbook . Here there is no attribute to specify the path of the host file.
default[‘hostsfile’][‘path’] = 'C:/Windows/System32/drivers/etc/hosts’
This is the way i have specified in th eattributes/default.rb
But how to specify this in the cookbook.
If using the latest version of
customink-webops/hostsfile then you shouldn’t even need to set
node['hostsfile']['path'] as it has
logic in the library to do this for you.
That said setting the attribute for the path can be done many ways including in the cookbook itself, a wrapper cookbook, a role, an environment, or you could set the attribute on the node itself.
If you’d like some more interactive assistance join us in the