Sensu data bag file

Hi

I am trying to use sensu with chef-solo. Chef requires a data_bag file. Unfortunately I can’t locate any info about what need to go into a data_bag file for the sensu package. I wonder if anyone can give me a pointer?

Currently I have put a file ‘mycompany.json’ in ~/.chef/data_bags/sensu/

The content of mycompany.json is just:

{
"id”:“mycompany”
}

This is the error message I am getting:

==> default: TypeError
==> default: ---------
==> default: can’t convert Array into String
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:36:in data_bag_item' ==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/recipes/default.rb:65:infrom_file’
==> default:
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:
==> default:
==> default: 29: “/opt/sensu/embedded/bin/gem”
==> default: 30: else
==> default: 31: “gem”
==> default: 32: end
==> default: 33: end
==> default: 34:
==> default: 35: def data_bag_item(item, missing_ok=false)
==> default: 36>> raw_hash = Chef::DataBagItem.load(“sensu”, item)

Thanks, Tony

Can you copy the chef-stacktrace.out file? Looks like you’re passing an unexpected data type somewhere, but it’s not checked until it blows up somewhere in chef’s internals.

--
Daniel DeLeo

On Monday, November 3, 2014 at 4:18 PM, A. Kong wrote:

Hi

I am trying to use sensu with chef-solo. Chef requires a data_bag file. Unfortunately I can’t locate any info about what need to go into a data_bag file for the sensu package. I wonder if anyone can give me a pointer?

Currently I have put a file ‘mycompany.json’ in ~/.chef/data_bags/sensu/

The content of mycompany.json is just:

{
"id”:"mycompany"
}

This is the error message I am getting:

==> default: TypeError
==> default: ---------
==> default: can't convert Array into String
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:36:in data_bag_item' ==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/recipes/default.rb:65:in from_file'
==> default:
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:
==> default:
==> default: 29: "/opt/sensu/embedded/bin/gem"
==> default: 30: else
==> default: 31: "gem"
==> default: 32: end
==> default: 33: end
==> default: 34:
==> default: 35: def data_bag_item(item, missing_ok=false)
==> default: 36>> raw_hash = Chef::DataBagItem.load("sensu", item)

Thanks, Tony

Hi Daniel,

Here is the content of /var/chef/cache/chef-stacktrace.out

Generated at 2014-11-04 11:40:08 +0000
Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/validation.pem, which you told me to use to sign requests!
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:74:in rescue in load_signing_key' /usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:64:in load_signing_key'
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:38:in initialize' /usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in new'
/usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in initialize' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in new'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in http_api' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:93:in create'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:84:in create_or_update' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:57:in run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:380:in register' /usr/lib/ruby/vendor_ruby/chef/client.rb:486:in do_run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:199:in block in run' /usr/lib/ruby/vendor_ruby/chef/client.rb:193:in fork'
/usr/lib/ruby/vendor_ruby/chef/client.rb:193:in run' /usr/lib/ruby/vendor_ruby/chef/application.rb:208:in run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:312:in block in run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in loop'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:66:in run'
/usr/bin/chef-client:25:in `'

BTW I have found out how to generate the data bag data file: https://github.com/sensu/sensu-chef/tree/master/examples/ssl https://github.com/sensu/sensu-chef/tree/master/examples/ssl

Cheers, Tony

On 4 Nov 2014, at 4:36 pm, Daniel DeLeo dan@kallistec.com wrote:

Can you copy the chef-stacktrace.out file? Looks like you’re passing an unexpected data type somewhere, but it’s not checked until it blows up somewhere in chef’s internals.

--
Daniel DeLeo

On Monday, November 3, 2014 at 4:18 PM, A. Kong wrote:

Hi

I am trying to use sensu with chef-solo. Chef requires a data_bag file. Unfortunately I can’t locate any info about what need to go into a data_bag file for the sensu package. I wonder if anyone can give me a pointer?

Currently I have put a file ‘mycompany.json’ in ~/.chef/data_bags/sensu/

The content of mycompany.json is just:

{
"id”:"mycompany"
}

This is the error message I am getting:

==> default: TypeError
==> default: ---------
==> default: can't convert Array into String
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:36:in data_bag_item' ==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/recipes/default.rb:65:in from_file'
==> default:
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:
==> default:
==> default: 29: "/opt/sensu/embedded/bin/gem"
==> default: 30: else
==> default: 31: "gem"
==> default: 32: end
==> default: 33: end
==> default: 34:
==> default: 35: def data_bag_item(item, missing_ok=false)
==> default: 36>> raw_hash = Chef::DataBagItem.load("sensu", item)

Thanks, Tony

On Tuesday, November 4, 2014 at 4:20 AM, A. Kong wrote:

Hi Daniel,

Here is the content of /var/chef/cache/chef-stacktrace.out

Generated at 2014-11-04 11:40:08 +0000
Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/validation.pem, which you told me to use to sign requests!
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:74:in rescue in load_signing_key' /usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:64:in load_signing_key'
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:38:in initialize' /usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in new'
/usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in initialize' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in new'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in http_api' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:93:in create'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:84:in create_or_update' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:57:in run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:380:in register' /usr/lib/ruby/vendor_ruby/chef/client.rb:486:in do_run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:199:in block in run' /usr/lib/ruby/vendor_ruby/chef/client.rb:193:in fork'
/usr/lib/ruby/vendor_ruby/chef/client.rb:193:in run' /usr/lib/ruby/vendor_ruby/chef/application.rb:208:in run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:312:in block in run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in loop'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:66:in run'
/usr/bin/chef-client:25:in `'

This looks like it’s from a different chef-client run, it’s indicating a failure to read the private key it needs to establish its identity with the Chef Server.

BTW I have found out how to generate the data bag data file: https://github.com/sensu/sensu-chef/tree/master/examples/ssl
But it looks like you got it sorted out. I’ll dig a little deeper and see if I can find where we can improve the error messages.

Cheers, Tony

--
Daniel DeLeo

On 4 Nov 2014, at 4:36 pm, Daniel DeLeo <dan@kallistec.com (mailto:dan@kallistec.com)> wrote:
Can you copy the chef-stacktrace.out file? Looks like you’re passing an unexpected data type somewhere, but it’s not checked until it blows up somewhere in chef’s internals.

--
Daniel DeLeo

On Monday, November 3, 2014 at 4:18 PM, A. Kong wrote:

Hi

I am trying to use sensu with chef-solo. Chef requires a data_bag file. Unfortunately I can’t locate any info about what need to go into a data_bag file for the sensu package. I wonder if anyone can give me a pointer?

Currently I have put a file ‘mycompany.json’ in ~/.chef/data_bags/sensu/

The content of mycompany.json is just:

{
"id”:"mycompany"
}

This is the error message I am getting:

==> default: TypeError
==> default: ---------
==> default: can't convert Array into String
==> default:
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:36:in data_bag_item' ==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/recipes/default.rb:65:in from_file'
==> default:
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef-3/chef-solo-1/cookbooks/sensu/libraries/sensu_helpers.rb:
==> default:
==> default: 29: "/opt/sensu/embedded/bin/gem"
==> default: 30: else
==> default: 31: "gem"
==> default: 32: end
==> default: 33: end
==> default: 34:
==> default: 35: def data_bag_item(item, missing_ok=false)
==> default: 36>> raw_hash = Chef::DataBagItem.load("sensu", item)

Thanks, Tony

On Tue, Nov 4, 2014 at 10:40 AM, Daniel DeLeo dan@kallistec.com wrote:

On Tuesday, November 4, 2014 at 4:20 AM, A. Kong wrote:

Hi Daniel,

Here is the content of /var/chef/cache/chef-stacktrace.out

Generated at 2014-11-04 11:40:08 +0000
Chef::Exceptions::PrivateKeyMissing: I cannot read /etc/chef/validation.pem, which you told me to use to sign requests!
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:74:in rescue in load_signing_key' /usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:64:in load_signing_key'
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:38:in initialize' /usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in new'
/usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in initialize' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in new'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in http_api' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:93:in create'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:84:in create_or_update' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:57:in run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:380:in register' /usr/lib/ruby/vendor_ruby/chef/client.rb:486:in do_run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:199:in block in run' /usr/lib/ruby/vendor_ruby/chef/client.rb:193:in fork'
/usr/lib/ruby/vendor_ruby/chef/client.rb:193:in run' /usr/lib/ruby/vendor_ruby/chef/application.rb:208:in run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:312:in block in run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in loop'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:66:in run'
/usr/bin/chef-client:25:in `'

This looks like it’s from a different chef-client run, it’s indicating a failure to read the private key it needs to establish its identity with the Chef Server.

Don't data bag item accesses assume you're in client-server mode and
thereby trigger the authentication code?

Tony, I'd suggest using chef-client in local mode rather than Solo if
you have data bags.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: http://www.aquezada.com/staff/julian * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

Hi Julian,

I am using chef-solo from vagrant. I probably should provide this context
at the beginning.

So in theory I shouldn't need to provide the data bag if I am just using
chef-solo. Is it right?

Cheers, Tony

On Wed, Nov 5, 2014 at 2:49 AM, Julian C. Dunn jdunn@aquezada.com wrote:

On Tue, Nov 4, 2014 at 10:40 AM, Daniel DeLeo dan@kallistec.com wrote:

On Tuesday, November 4, 2014 at 4:20 AM, A. Kong wrote:

Hi Daniel,

Here is the content of /var/chef/cache/chef-stacktrace.out

Generated at 2014-11-04 11:40:08 +0000
Chef::Exceptions::PrivateKeyMissing: I cannot read
/etc/chef/validation.pem, which you told me to use to sign requests!
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:74:in rescue in load_signing_key' /usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:64:in load_signing_key'
/usr/lib/ruby/vendor_ruby/chef/http/authenticator.rb:38:in initialize' /usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in new'
/usr/lib/ruby/vendor_ruby/chef/rest.rb:63:in initialize' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in new'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:111:in
http_api' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:93:in create'
/usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:84:in
create_or_update' /usr/lib/ruby/vendor_ruby/chef/api_client/registration.rb:57:in run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:380:in register' /usr/lib/ruby/vendor_ruby/chef/client.rb:486:in do_run'
/usr/lib/ruby/vendor_ruby/chef/client.rb:199:in block in run' /usr/lib/ruby/vendor_ruby/chef/client.rb:193:in fork'
/usr/lib/ruby/vendor_ruby/chef/client.rb:193:in run' /usr/lib/ruby/vendor_ruby/chef/application.rb:208:in run_chef_client'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:312:in block in run_application' /usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in loop'
/usr/lib/ruby/vendor_ruby/chef/application/client.rb:304:in
run_application' /usr/lib/ruby/vendor_ruby/chef/application.rb:66:in run'
/usr/bin/chef-client:25:in `'

This looks like it’s from a different chef-client run, it’s indicating a
failure to read the private key it needs to establish its identity with the
Chef Server.

Don't data bag item accesses assume you're in client-server mode and
thereby trigger the authentication code?

Tony, I'd suggest using chef-client in local mode rather than Solo if
you have data bags.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

On Wed, Nov 5, 2014 at 5:29 PM, Anthony Kong anthony.hw.kong@gmail.com wrote:

I am using chef-solo from vagrant. I probably should provide this context at
the beginning.

So in theory I shouldn't need to provide the data bag if I am just using
chef-solo. Is it right?

It depends how the author wrote the cookbook you're trying to use.
Based on your description, it sounds like they assume you are using
Chef Client (or at least Chef Client in local mode), and if so, you'll
need to provide a data bag.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

See solo.rb for how to set the
data_bag path for chef-solo, and also see the README.md in the sensu-chef
cookbook, where it says:

TESTING

This cookbook comes with a Gemfile, Cheffile, and a Vagrantfile for testing
and evaluating Sensu.

cd examples
gem install bundler
bundle install
librarian-chef install
vagrant up
vagrant ssh

Hope that helps,

Peter

On Wed, Nov 5, 2014 at 5:36 PM, Julian C. Dunn jdunn@aquezada.com wrote:

On Wed, Nov 5, 2014 at 5:29 PM, Anthony Kong anthony.hw.kong@gmail.com
wrote:

I am using chef-solo from vagrant. I probably should provide this
context at
the beginning.

So in theory I shouldn't need to provide the data bag if I am just using
chef-solo. Is it right?

It depends how the author wrote the cookbook you're trying to use.
Based on your description, it sounds like they assume you are using
Chef Client (or at least Chef Client in local mode), and if so, you'll
need to provide a data bag.

  • Julian

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]