Metadata and cookbook names

Hi guys,

A have a couple of questions in this area:

  1. Is the metadata.rb file mandatory in a cookbook?
  2. if metadata.rb is present, and it specifies a different name than
    the cookbook archive filename, which is the name considered by
    cookbook dependency resolution alg during a chef-run?

Thanks,
Lucian

  1. Assume metadata.rb is required. I am not 100% sure if Chef can operate
    without one in the cookbook, but you should set up a commit hook so that it
    forces the metadata.rb file to exist.

  2. The name is metadata.rb is respected. All dependency resolvers should
    unpack the cookbooks and parse the metadata file to find the name.

For an example check out "cookbook-elasticsearch".

The name in metadata.rb is "elasticsearch" and that is how it is referred
to internally.

On Fri, Oct 11, 2013 at 9:50 AM, Lucian Ciufudean <
lucian.ciufudean@gmail.com> wrote:

Hi guys,

A have a couple of questions in this area:

  1. Is the metadata.rb file mandatory in a cookbook?
  2. if metadata.rb is present, and it specifies a different name than
    the cookbook archive filename, which is the name considered by
    cookbook dependency resolution alg during a chef-run?

Thanks,
Lucian

metadata.rb is definitely required.

In fact, I believe the cookbook name in metadata.rb is actually honored
over the directory name...

On Fri, Oct 11, 2013 at 8:08 AM, Andrew Gross andrew@yipit.com wrote:

  1. Assume metadata.rb is required. I am not 100% sure if Chef can operate
    without one in the cookbook, but you should set up a commit hook so that it
    forces the metadata.rb file to exist.

  2. The name is metadata.rb is respected. All dependency resolvers should
    unpack the cookbooks and parse the metadata file to find the name.

For an example check out "cookbook-elasticsearch".

elasticsearch/metadata.rb at main · sous-chefs/elasticsearch · GitHub

The name in metadata.rb is "elasticsearch" and that is how it is referred
to internally.

On Fri, Oct 11, 2013 at 9:50 AM, Lucian Ciufudean <
lucian.ciufudean@gmail.com> wrote:

Hi guys,

A have a couple of questions in this area:

  1. Is the metadata.rb file mandatory in a cookbook?
  2. if metadata.rb is present, and it specifies a different name than
    the cookbook archive filename, which is the name considered by
    cookbook dependency resolution alg during a chef-run?

Thanks,
Lucian

Thanks, I asked this because I'm seeing all kinds of community
content. For example cookbook 'subversion' got a name attribute in
metadata.rb only 11 months ago.

On Fri, Oct 11, 2013 at 11:04 PM, steve . leftathome@gmail.com wrote:

metadata.rb is definitely required.

In fact, I believe the cookbook name in metadata.rb is actually honored over
the directory name...

On Fri, Oct 11, 2013 at 8:08 AM, Andrew Gross andrew@yipit.com wrote:

  1. Assume metadata.rb is required. I am not 100% sure if Chef can operate
    without one in the cookbook, but you should set up a commit hook so that it
    forces the metadata.rb file to exist.

  2. The name is metadata.rb is respected. All dependency resolvers should
    unpack the cookbooks and parse the metadata file to find the name.

For an example check out "cookbook-elasticsearch".

elasticsearch/metadata.rb at main · sous-chefs/elasticsearch · GitHub

The name in metadata.rb is "elasticsearch" and that is how it is referred
to internally.

On Fri, Oct 11, 2013 at 9:50 AM, Lucian Ciufudean
lucian.ciufudean@gmail.com wrote:

Hi guys,

A have a couple of questions in this area:

  1. Is the metadata.rb file mandatory in a cookbook?
  2. if metadata.rb is present, and it specifies a different name than
    the cookbook archive filename, which is the name considered by
    cookbook dependency resolution alg during a chef-run?

Thanks,
Lucian

In case it helps anyone, here is a test using chef-solo that shows
that the name in metadata.rb is not used by chef-solo, as opposed to
the name of the cookbook folder. This is true also for naming
dependencies, use the cookbook root folder and not the name in
metadata.

This seems to contradict the specs.

[root@localhost cookbooks]# chef-solo --version
Chef: 11.4.4
[root@localhost cookbooks]# ls -l | grep test
drwxr-xr-x 7 root root 4096 Oct 22 04:55 test_compliance
[root@localhost cookbooks]# cat test_compliance/metadata.rb
version "1.0"
supports 'windows'
name 'fake_name'

[root@localhost cookbooks]# chef-solo -o fake_name::echo
Starting Chef Client, version 11.4.4
[2013-10-22T04:58:39+00:00] WARN: Run List override has been provided.
[2013-10-22T04:58:39+00:00] WARN: Original Run List:
[2013-10-22T04:58:39+00:00] WARN: Overridden Run List: [recipe[fake_name::echo]]
Compiling Cookbooks...
[2013-10-22T04:58:39+00:00] ERROR: Running exception handlers
[2013-10-22T04:58:39+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-10-22T04:58:39+00:00] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[2013-10-22T04:58:39+00:00] FATAL: Chef::Exceptions::CookbookNotFound:
Cookbook fake_name not found. If you're loading fake_name from another
cookbook, make sure you configure the dependency in your metadata

Lucian

On Tue, Oct 15, 2013 at 2:06 PM, Lucian Ciufudean
lucian.ciufudean@gmail.com wrote:

Thanks, I asked this because I'm seeing all kinds of community
content. For example cookbook 'subversion' got a name attribute in
metadata.rb only 11 months ago.

On Fri, Oct 11, 2013 at 11:04 PM, steve . leftathome@gmail.com wrote:

metadata.rb is definitely required.

In fact, I believe the cookbook name in metadata.rb is actually honored over
the directory name...

On Fri, Oct 11, 2013 at 8:08 AM, Andrew Gross andrew@yipit.com wrote:

  1. Assume metadata.rb is required. I am not 100% sure if Chef can operate
    without one in the cookbook, but you should set up a commit hook so that it
    forces the metadata.rb file to exist.

  2. The name is metadata.rb is respected. All dependency resolvers should
    unpack the cookbooks and parse the metadata file to find the name.

For an example check out "cookbook-elasticsearch".

elasticsearch/metadata.rb at main · sous-chefs/elasticsearch · GitHub

The name in metadata.rb is "elasticsearch" and that is how it is referred
to internally.

On Fri, Oct 11, 2013 at 9:50 AM, Lucian Ciufudean
lucian.ciufudean@gmail.com wrote:

Hi guys,

A have a couple of questions in this area:

  1. Is the metadata.rb file mandatory in a cookbook?
  2. if metadata.rb is present, and it specifies a different name than
    the cookbook archive filename, which is the name considered by
    cookbook dependency resolution alg during a chef-run?

Thanks,
Lucian

This is being being tracked here:

https://tickets.opscode.com/browse/CHEF-3490

On Tue, Oct 22, 2013 at 8:34 AM, Lucian Ciufudean <
lucian.ciufudean@gmail.com> wrote:

In case it helps anyone, here is a test using chef-solo that shows
that the name in metadata.rb is not used by chef-solo, as opposed to
the name of the cookbook folder. This is true also for naming
dependencies, use the cookbook root folder and not the name in
metadata.

This seems to contradict the specs.

[root@localhost cookbooks]# chef-solo --version
Chef: 11.4.4
[root@localhost cookbooks]# ls -l | grep test
drwxr-xr-x 7 root root 4096 Oct 22 04:55 test_compliance
[root@localhost cookbooks]# cat test_compliance/metadata.rb
version "1.0"
supports 'windows'
name 'fake_name'

[root@localhost cookbooks]# chef-solo -o fake_name::echo
Starting Chef Client, version 11.4.4
[2013-10-22T04:58:39+00:00] WARN: Run List override has been provided.
[2013-10-22T04:58:39+00:00] WARN: Original Run List:
[2013-10-22T04:58:39+00:00] WARN: Overridden Run List:
[recipe[fake_name::echo]]
Compiling Cookbooks...
[2013-10-22T04:58:39+00:00] ERROR: Running exception handlers
[2013-10-22T04:58:39+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated
[2013-10-22T04:58:39+00:00] FATAL: Stacktrace dumped to
/var/chef/cache/chef-stacktrace.out
[2013-10-22T04:58:39+00:00] FATAL: Chef::Exceptions::CookbookNotFound:
Cookbook fake_name not found. If you're loading fake_name from another
cookbook, make sure you configure the dependency in your metadata

Lucian

On Tue, Oct 15, 2013 at 2:06 PM, Lucian Ciufudean
lucian.ciufudean@gmail.com wrote:

Thanks, I asked this because I'm seeing all kinds of community
content. For example cookbook 'subversion' got a name attribute in
metadata.rb only 11 months ago.

On Fri, Oct 11, 2013 at 11:04 PM, steve . leftathome@gmail.com wrote:

metadata.rb is definitely required.

In fact, I believe the cookbook name in metadata.rb is actually honored
over
the directory name...

On Fri, Oct 11, 2013 at 8:08 AM, Andrew Gross andrew@yipit.com wrote:

  1. Assume metadata.rb is required. I am not 100% sure if Chef can
    operate
    without one in the cookbook, but you should set up a commit hook so
    that it
    forces the metadata.rb file to exist.

  2. The name is metadata.rb is respected. All dependency resolvers
    should
    unpack the cookbooks and parse the metadata file to find the name.

For an example check out "cookbook-elasticsearch".

elasticsearch/metadata.rb at main · sous-chefs/elasticsearch · GitHub

The name in metadata.rb is "elasticsearch" and that is how it is
referred
to internally.

On Fri, Oct 11, 2013 at 9:50 AM, Lucian Ciufudean
lucian.ciufudean@gmail.com wrote:

Hi guys,

A have a couple of questions in this area:

  1. Is the metadata.rb file mandatory in a cookbook?
  2. if metadata.rb is present, and it specifies a different name than
    the cookbook archive filename, which is the name considered by
    cookbook dependency resolution alg during a chef-run?

Thanks,
Lucian