Checksum values in attribute files


#1

We’re trying to do something pretty simple: Include a checksum value as a
default attribute within a defaults attribute file.

default[‘foo’][‘package’][‘checksum’] =
‘c22bb6a227359748618ca1f6fc31b6a05fef3f19dc8251ffb15233b775cd6aff’

But when the associated cookbook is compiled, we encounter the following error.

Do you know why this error is occurring?

If we hard code reference to the checksum within the recipe, it works fine.

If we fabricate a hash and include the checksum in it within the attributes
file, it works fine.

[2013-07-22T15:53:35-05:00] INFO: Start handlers complete.
Compiling Cookbooks…

================================================================================
Recipe Compile Error in /…/chef/cookbooks/foo/attributes/default.rb

IndexError

string not matched

Cookbook Trace:

/…/chef/cookbooks/foo/attributes/default.rb:6:in []=' /.../chef/cookbooks/foo/attributes/default.rb:6:infrom_file’

Relevant File Content:

/…/chef/cookbooks/foo/attributes/default.rb:

1: …

6>> default[‘foo’][‘package’][‘checksum’] =
'c22bb6a227359748618ca1f6fc31b6a05fef3f19dc8251ffb15233b775cd6aff’
7: …


#2

Is the checksum string actually on its own line, or is that just formatting?

We’re trying to do something pretty simple: Include a checksum value as a
default attribute within a defaults attribute file.

default[‘foo’][‘package’][‘checksum’] =
‘c22bb6a227359748618ca1f6fc31b6a05fef3f19dc8251ffb15233b775cd6aff’

But when the associated cookbook is compiled, we encounter the following error.

Do you know why this error is occurring?

If we hard code reference to the checksum within the recipe, it works fine.

If we fabricate a hash and include the checksum in it within the attributes
file, it works fine.

[2013-07-22T15:53:35-05:00] INFO: Start handlers complete.
Compiling Cookbooks…

================================================================================
Recipe Compile Error in /…/chef/cookbooks/foo/attributes/default.rb

IndexError

string not matched

Cookbook Trace:

/…/chef/cookbooks/foo/attributes/default.rb:6:in []=' /.../chef/cookbooks/foo/attributes/default.rb:6:infrom_file’

Relevant File Content:

/…/chef/cookbooks/foo/attributes/default.rb:

1: …

6>> default[‘foo’][‘package’][‘checksum’] =
'c22bb6a227359748618ca1f6fc31b6a05fef3f19dc8251ffb15233b775cd6aff’
7: …


#3

On Monday, July 22, 2013 at 2:37 PM, Lucas Hansen wrote:

IndexError

string not matched

Cookbook Trace:

/…/chef/cookbooks/foo/attributes/default.rb:6:in []=' /.../chef/cookbooks/foo/attributes/default.rb:6:infrom_file’

Relevant File Content:

/…/chef/cookbooks/foo/attributes/default.rb:

1: …

6>> default[‘foo’][‘package’][‘checksum’] =
‘c22bb6a227359748618ca1f6fc31b6a05fef3f19dc8251ffb15233b775cd6aff’

Is default[“foo”][“package”] set to a string?

Looks like the same error as this:

irb(main):004:0> “xyz”[“a”] = "b"
IndexError: string not matched
from (irb):4:in `[]=’


Daniel DeLeo


#4

Excellent. That was the issue. Since we’re so used to representing a
hierarchy of attributes, we lost sight of this special circumstance. It’s a
wonder that we don’t encounter this more often.

Thanks for your insight.

On Monday, July 22, 2013, Daniel DeLeo wrote:

On Monday, July 22, 2013 at 2:37 PM, Lucas Hansen wrote:

IndexError

string not matched

Cookbook Trace:

/…/chef/cookbooks/foo/attributes/default.rb:6:in []=' /.../chef/cookbooks/foo/attributes/default.rb:6:infrom_file’

Relevant File Content:

/…/chef/cookbooks/foo/attributes/default.rb:

1: …

6>> default[‘foo’][‘package’][‘checksum’] =
‘c22bb6a227359748618ca1f6fc31b6a05fef3f19dc8251ffb15233b775cd6aff’

Is default[“foo”][“package”] set to a string?

Looks like the same error as this:

irb(main):004:0> “xyz”[“a”] = "b"
IndexError: string not matched
from (irb):4:in `[]=’


Daniel DeLeo