Cannot find a resource for hostsfile_entry on ubuntu

Hi,

I’ve installed cookbook hostname but neither me neither chef could find the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry “localhost” do
50: hostsfile_entry “set hostname” do

Anyone ?

Cyril SCETBON

Does cookbooks/hostname/metadata.rb contain the line: “depends hostsfile” ?

On Thu, Jan 16, 2014 at 3:28 PM, Cyril Scetbon cyril.scetbon@free.frwrote:

Hi,

I've installed cookbook hostname but neither me neither chef could find
the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry "localhost" do
50: hostsfile_entry "set hostname" do

Anyone ?

Cyril SCETBON

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com
Linkedinhttp://www.linkedin.com/in/gmiranda23/
Twitter https://twitter.com/gmiranda23

CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Bloghttp://www.opscode.com/blog/
Facebook https://www.facebook.com/getchefdotcom
Twitterhttps://twitter.com/getchefdotcom
Youtube https://www.youtube.com/getchef

Meet me at #ChefConf 2014 http://chefconf.com/

yes :

$ grep depends ../../hostname/metadata.rb
depends "hostsfile"

--
Cyril SCETBON

On 17 Jan 2014, at 00:33, George Miranda gmiranda@getchef.com wrote:

Does cookbooks/hostname/metadata.rb contain the line: “depends hostsfile” ?

On Thu, Jan 16, 2014 at 3:28 PM, Cyril Scetbon cyril.scetbon@free.fr wrote:
Hi,

I've installed cookbook hostname but neither me neither chef could find the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry "localhost" do
50: hostsfile_entry "set hostname" do

Anyone ?

Cyril SCETBON

--
George Miranda — Consulting
512.481.2876 – gmiranda@getchef.com – Linkedin Twitter

CHEF
GETCHEF.COM

TM
getchef.com Blog Facebook Twitter Youtube

Meet me at #ChefConf 2014

Hi Cyril,

There’s not enough information to go on. Can you provide some additional
stats? It would help to have: cookbook version for each (I’m guessing
you’re using the community cookbooks named ‘hostname’ and ‘hostsfile’?) as
well as a stacktrace of the chef run (chef-client? chef-solo?) giving you
an error, and which platform you’re running this on.

You can remove any sensitive information from the logs. But the more info
you can provide, the easier it will be to troubleshoot.

On Fri, Jan 17, 2014 at 1:22 AM, Cyril Scetbon cyril.scetbon@free.frwrote:

yes :

$ grep depends ../../hostname/metadata.rb
depends "hostsfile"

--
Cyril SCETBON

On 17 Jan 2014, at 00:33, George Miranda gmiranda@getchef.com wrote:

Does cookbooks/hostname/metadata.rb contain the line: “depends hostsfile”
?

On Thu, Jan 16, 2014 at 3:28 PM, Cyril Scetbon cyril.scetbon@free.frwrote:

Hi,

I've installed cookbook hostname but neither me neither chef could find
the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry "localhost" do
50: hostsfile_entry "set hostname" do

Anyone ?

Cyril SCETBON

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com – Linkedinhttp://www.linkedin.com/in/gmiranda23/
Twitter https://twitter.com/gmiranda23
CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Bloghttp://www.opscode.com/blog/
Facebook https://www.facebook.com/getchefdotcom Twitterhttps://twitter.com/getchefdotcom
Youtube https://www.youtube.com/getchef

Meet me at #ChefConf 2014 http://chefconf.com/

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com
Linkedinhttp://www.linkedin.com/in/gmiranda23/
Twitter https://twitter.com/gmiranda23

CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Bloghttp://www.opscode.com/blog/
Facebook https://www.facebook.com/getchefdotcom
Twitterhttps://twitter.com/getchefdotcom
Youtube https://www.youtube.com/getchef

Meet me at #ChefConf 2014 http://chefconf.com/

What hostsfile cookbook are you using? Is it this one? GitHub - customink-webops/hostsfile: Easily manage your hosts file with Chef http://community.opscode.com/cookbooks/hostsfile

Looking at the code on github, this file should be providing the hostsfile_entry resource: https://github.com/customink-webops/hostsfile/blob/master/resources/entry.rb Note that the name of the resource is inferred from the cookbook name plus an underscore plus the file name so you won’t necessarily see the string “hostsfile_entry” in the source.

In any case, try running with debug logging (chef-client -ldebug) and look for a message like "Loading cookbook #{cookbook_name}'s resources from #{filename}” to confirm that the cookbook is getting loaded.

--
Daniel DeLeo

On Friday, January 17, 2014 at 8:42 AM, George Miranda wrote:

Hi Cyril,

There’s not enough information to go on. Can you provide some additional stats? It would help to have: cookbook version for each (I’m guessing you’re using the community cookbooks named ‘hostname’ and ‘hostsfile’?) as well as a stacktrace of the chef run (chef-client? chef-solo?) giving you an error, and which platform you’re running this on.

You can remove any sensitive information from the logs. But the more info you can provide, the easier it will be to troubleshoot.

On Fri, Jan 17, 2014 at 1:22 AM, Cyril Scetbon <cyril.scetbon@free.fr (mailto:cyril.scetbon@free.fr)> wrote:

yes :

$ grep depends ../../hostname/metadata.rb
depends "hostsfile"

--
Cyril SCETBON

On 17 Jan 2014, at 00:33, George Miranda <gmiranda@getchef.com (mailto:gmiranda@getchef.com)> wrote:

Does cookbooks/hostname/metadata.rb contain the line: “depends hostsfile” ?

On Thu, Jan 16, 2014 at 3:28 PM, Cyril Scetbon <cyril.scetbon@free.fr (mailto:cyril.scetbon@free.fr)> wrote:

Hi,

I've installed cookbook hostname but neither me neither chef could find the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md (http://README.md)
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md (http://CHANGELOG.md)
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md (http://README.md)
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md (http://CHANGELOG.md)
├── README.md (http://README.md)
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry "localhost" do
50: hostsfile_entry "set hostname" do

Anyone ?

Cyril SCETBON

--

George Miranda — Consulting

512.481.2876 (tel:512.481.2876) – gmiranda@getchef.com (mailto:gmiranda@getchef.com) – Linkedin (http://www.linkedin.com/in/gmiranda23/) Twitter (https://twitter.com/gmiranda23)

CHEF

GETCHEF.COM (http://www.getchef.com/)

TM

getchef.com (http://www.getchef.com/) Blog (Chef Blog - IT Automation for everything from configuration management to continuous delivery. | Chef) Facebook (Progress Chef | Seattle WA) Twitter (https://twitter.com/getchefdotcom) Youtube (https://www.youtube.com/getchef)

Meet me at #ChefConf 2014 (http://chefconf.com/)

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com (mailto:gmiranda@getchef.com) – Linkedin (http://www.linkedin.com/in/gmiranda23/) Twitter (https://twitter.com/gmiranda23)

CHEF

GETCHEF.COM (http://www.getchef.com/)

TM

getchef.com (http://www.getchef.com/) Blog (Chef Blog - IT Automation for everything from configuration management to continuous delivery. | Chef) Facebook (Progress Chef | Seattle WA) Twitter (https://twitter.com/getchefdotcom) Youtube (https://www.youtube.com/getchef)

Meet me at #ChefConf 2014 (http://chefconf.com/)

On 17 Jan 2014, at 20:21, Daniel DeLeo dan@kallistec.com wrote:

What hostsfile cookbook are you using? Is it this one? GitHub - customink-webops/hostsfile: Easily manage your hosts file with Chef http://community.opscode.com/cookbooks/hostsfile

Looking at the code on github, this file should be providing the hostsfile_entry resource: https://github.com/customink-webops/hostsfile/blob/master/resources/entry.rb Note that the name of the resource is inferred from the cookbook name plus an underscore plus the file name so you won’t necessarily see the string “hostsfile_entry” in the source.

ok you're right this file is included and contains functions. I've finally made it work with a new fresh repository. where can I find more information about this naming conventions and how it works ? is it related to ruby (I'm not yet an experimented ruby coder) ?

thanks

In any case, try running with debug logging (chef-client -ldebug) and look for a message like "Loading cookbook #{cookbook_name}'s resources from #{filename}” to confirm that the cookbook is getting loaded.

--
Daniel DeLeo

On Friday, January 17, 2014 at 8:42 AM, George Miranda wrote:

Hi Cyril,

There’s not enough information to go on. Can you provide some additional stats? It would help to have: cookbook version for each (I’m guessing you’re using the community cookbooks named ‘hostname’ and ‘hostsfile’?) as well as a stacktrace of the chef run (chef-client? chef-solo?) giving you an error, and which platform you’re running this on.

You can remove any sensitive information from the logs. But the more info you can provide, the easier it will be to troubleshoot.

On Fri, Jan 17, 2014 at 1:22 AM, Cyril Scetbon cyril.scetbon@free.fr wrote:

yes :

$ grep depends ../../hostname/metadata.rb
depends "hostsfile"

--
Cyril SCETBON

On 17 Jan 2014, at 00:33, George Miranda gmiranda@getchef.com wrote:

Does cookbooks/hostname/metadata.rb contain the line: “depends hostsfile” ?

On Thu, Jan 16, 2014 at 3:28 PM, Cyril Scetbon cyril.scetbon@free.fr wrote:

Hi,

I've installed cookbook hostname but neither me neither chef could find the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md
├── README.md
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry "localhost" do
50: hostsfile_entry "set hostname" do

Anyone ?

Cyril SCETBON

--
George Miranda — Consulting
512.481.2876 – gmiranda@getchef.com – Linkedin Twitter

CHEF
GETCHEF.COM

TM
getchef.com Blog Facebook Twitter Youtube

Meet me at #ChefConf 2014

--
George Miranda — Consulting
512.481.2876 – gmiranda@getchef.com – Linkedin Twitter

CHEF
GETCHEF.COM

TM
getchef.com Blog Facebook Twitter Youtube

Meet me at #ChefConf 2014

Chef allows making custom resources through LWRPs. A “LightWeight Resource
and Provider” inherits the name of the cookbook that defines it. So when
you see a resource not included in the Chef framework and it’s name is
“hostsfile_entry”, that means a cookbook called “hostsfile” has a defined
resource called “entry” in hostsfile/resources/entry.rb and a defined
provider in hostsfile/providers/entry.rb.

The LWRP reference should shed more light on this.
http://docs.opscode.com/lwrp.html

Also, there’s this great tutorial:
http://dougireton.com/blog/2012/12/31/creating-an-lwrp/

HTH,

-George

On Fri, Jan 17, 2014 at 12:06 PM, Cyril Scetbon cyril.scetbon@free.frwrote:

On 17 Jan 2014, at 20:21, Daniel DeLeo dan@kallistec.com wrote:

What hostsfile cookbook are you using? Is it this one?
GitHub - customink-webops/hostsfile: Easily manage your hosts file with Chef
http://community.opscode.com/cookbooks/hostsfile

Looking at the code on github, this file should be providing the
hostsfile_entry resource:
https://github.com/customink-webops/hostsfile/blob/master/resources/entry.rbNote that the name of the resource is inferred from the cookbook name plus
an underscore plus the file name so you won’t necessarily see the string
“hostsfile_entry” in the source.

ok you're right this file is included and contains functions. I've finally
made it work with a new fresh repository. where can I find more information
about this naming conventions and how it works ? is it related to ruby (I'm
not yet an experimented ruby coder) ?

thanks

In any case, try running with debug logging (chef-client -ldebug) and
look for a message like "Loading cookbook #{cookbook_name}'s resources from
#{filename}” to confirm that the cookbook is getting loaded.

--
Daniel DeLeo

On Friday, January 17, 2014 at 8:42 AM, George Miranda wrote:

Hi Cyril,

There’s not enough information to go on. Can you provide some additional
stats? It would help to have: cookbook version for each (I’m guessing
you’re using the community cookbooks named ‘hostname’ and ‘hostsfile’?) as
well as a stacktrace of the chef run (chef-client? chef-solo?) giving you
an error, and which platform you’re running this on.

You can remove any sensitive information from the logs. But the more info
you can provide, the easier it will be to troubleshoot.

On Fri, Jan 17, 2014 at 1:22 AM, Cyril Scetbon cyril.scetbon@free.frwrote:

yes :

$ grep depends ../../hostname/metadata.rb
depends "hostsfile"

--
Cyril SCETBON

On 17 Jan 2014, at 00:33, George Miranda gmiranda@getchef.com wrote:

Does cookbooks/hostname/metadata.rb contain the line: “depends hostsfile”
?

On Thu, Jan 16, 2014 at 3:28 PM, Cyril Scetbon cyril.scetbon@free.frwrote:

Hi,

I've installed cookbook hostname but neither me neither chef could find
the resource hostsfile_entry :

$ tree cookbooks
cookbooks
├── README.md http://readme.md/
├── hostname
│ ├── Berksfile
│ ├── Berksfile.lock
│ ├── CHANGELOG.md http://changelog.md/
│ ├── Gemfile
│ ├── Gemfile.lock
│ ├── Gemfile~
│ ├── README.md http://readme.md/
│ ├── Rakefile
│ ├── Strainerfile
│ ├── metadata.json
│ ├── metadata.rb
│ └── recipes
│ ├── default.rb
│ └── vmware.rb
└── hostsfile
├── CHANGELOG.md http://changelog.md/
├── README.md http://readme.md/
├── attributes
│ └── default.rb
├── libraries
│ ├── entry.rb
│ └── manipulator.rb
├── metadata.json
├── metadata.rb
├── providers
│ └── entry.rb
└── resources
└── entry.rb

$ ack -i --ruby hostsfile_entry .
cookbooks/hostname/recipes/default.rb
44: hostsfile_entry "localhost" do
50: hostsfile_entry "set hostname" do

Anyone ?

Cyril SCETBON

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com – Linkedinhttp://www.linkedin.com/in/gmiranda23/
Twitter https://twitter.com/gmiranda23
CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Bloghttp://www.opscode.com/blog/
Facebook https://www.facebook.com/getchefdotcom Twitterhttps://twitter.com/getchefdotcom
Youtube https://www.youtube.com/getchef

Meet me at #ChefConf 2014 http://chefconf.com/

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com – Linkedinhttp://www.linkedin.com/in/gmiranda23/
Twitter https://twitter.com/gmiranda23
CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Bloghttp://www.opscode.com/blog/
Facebook https://www.facebook.com/getchefdotcom Twitterhttps://twitter.com/getchefdotcom
Youtube https://www.youtube.com/getchef

Meet me at #ChefConf 2014 http://chefconf.com/

--

George Miranda — Consulting

512.481.2876 – gmiranda@getchef.com
Linkedinhttp://www.linkedin.com/in/gmiranda23/
Twitter https://twitter.com/gmiranda23

CHEF

GETCHEF.COM http://www.getchef.com/

TM

getchef.com http://www.getchef.com/ Bloghttp://www.opscode.com/blog/
Facebook https://www.facebook.com/getchefdotcom
Twitterhttps://twitter.com/getchefdotcom
Youtube https://www.youtube.com/getchef

Meet me at #ChefConf 2014 http://chefconf.com/

On Friday, January 17, 2014 at 12:06 PM, Cyril Scetbon wrote:

On 17 Jan 2014, at 20:21, Daniel DeLeo <dan@kallistec.com (mailto:dan@kallistec.com)> wrote:

What hostsfile cookbook are you using? Is it this one? GitHub - customink-webops/hostsfile: Easily manage your hosts file with Chef http://community.opscode.com/cookbooks/hostsfile

Looking at the code on github, this file should be providing the hostsfile_entry resource: https://github.com/customink-webops/hostsfile/blob/master/resources/entry.rb Note that the name of the resource is inferred from the cookbook name plus an underscore plus the file name so you won’t necessarily see the string “hostsfile_entry” in the source.

ok you're right this file is included and contains functions. I've finally made it work with a new fresh repository. where can I find more information about this naming conventions and how it works ? is it related to ruby (I'm not yet an experimented ruby coder) ?
Generally this stuff should be on the docs site, e.g., http://docs.opscode.com/lwrp_custom_resource.html In this case that page doesn’t describe the naming conventions for LWRP resources, so I’ll get in touch with our technical writer about this.

The naming conventions in Chef are generally defined by Chef’s code and not general ruby things. For example, a Chef resource can have any name that is a valid ruby method name and correctly converts to the proper ruby class name (this is based on how Chef converts snake_case_method_names into CamelCaseClassNames). That said, the LWRP DSL removes all of the boilerplate of class definitions so there’s no place for a user to specify what name they want the resource to have, which means that Chef picks the name based on its own conventions.

HTH,

--
Daniel DeLeo

Yes it helps
Thank you guys !

Cyril Scetbon

Le 17 janv. 2014 à 21:56, Daniel DeLeo dan@kallistec.com a écrit :

On Friday, January 17, 2014 at 12:06 PM, Cyril Scetbon wrote:

On 17 Jan 2014, at 20:21, Daniel DeLeo dan@kallistec.com wrote:

What hostsfile cookbook are you using? Is it this one? GitHub - customink-webops/hostsfile: Easily manage your hosts file with Chef http://community.opscode.com/cookbooks/hostsfile

Looking at the code on github, this file should be providing the hostsfile_entry resource: https://github.com/customink-webops/hostsfile/blob/master/resources/entry.rb Note that the name of the resource is inferred from the cookbook name plus an underscore plus the file name so you won’t necessarily see the string “hostsfile_entry” in the source.
ok you're right this file is included and contains functions. I've finally made it work with a new fresh repository. where can I find more information about this naming conventions and how it works ? is it related to ruby (I'm not yet an experimented ruby coder) ?
Generally this stuff should be on the docs site, e.g., http://docs.opscode.com/lwrp_custom_resource.html In this case that page doesn’t describe the naming conventions for LWRP resources, so I’ll get in touch with our technical writer about this.

The naming conventions in Chef are generally defined by Chef’s code and not general ruby things. For example, a Chef resource can have any name that is a valid ruby method name and correctly converts to the proper ruby class name (this is based on how Chef converts snake_case_method_names into CamelCaseClassNames). That said, the LWRP DSL removes all of the boilerplate of class definitions so there’s no place for a user to specify what name they want the resource to have, which means that Chef picks the name based on its own conventions.

HTH,

--
Daniel DeLeo