[chef] Chef-zero and invalid sensu data-bag


Chronological Thread 
  • From: Anthony Kong < >
  • To:
  • Subject: [chef] Chef-zero and invalid sensu data-bag
  • Date: Wed, 28 Jan 2015 17:13:02 +1100

Hi,

I am getting data bag error when I tried to install sensu via vargant/chef. Here is some output


==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/antkong/dev/zeetings/aws/vagrant-setup/01-sensu-server
    default: /tmp/vagrant-cache => /Users/antkong/.vagrant.d/cache/ubuntu/trusty64
    default: /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks => /Users/antkong/.berkshelf/vagrant-berkshelf/shelves/berkshelf20150128-2618-1t2vwq6-default
==> default: Installing Chef 12.0.3 Omnibus package...
==> default: Downloading Chef 12.0.3 for ubuntu...
==> default:   to file /tmp/install.sh.2131/metadata.txt
==> default: trying wget...
==> default: md5 76910abba3f7902d1b4d176f7a568c3a
==> default: sha256 3e172853aa0bcc27415a14b1013811dd44e5f523f4ba34714b66191ba365e796
==> default: downloaded metadata file looks valid...
==> default: /tmp/vagrant-cache/vagrant_omnibus/chef_12.0.3-1_amd64.deb already exists, verifiying checksum...
==> default: Comparing checksum with sha256sum...
==> default: checksum compare succeeded, using existing file!
==> default: Installing Chef 12.0.3
==> default: installing with dpkg...
==> default: (Reading database ... 60959 files and directories currently installed.)
==> default: Preparing to unpack .../chef_12.0.3-1_amd64.deb ...
==> default:  * Stopping chef-client chef-client
==> default:    ...done.
==> default: Unpacking chef (12.0.3-1) over (11.8.2-2) ...
==> default: dpkg: warning: unable to delete old directory '/var/log/chef': Directory not empty
==> default: dpkg: warning: unable to delete old directory '/etc/chef': Directory not empty
==> default: Setting up chef (12.0.3-1) ...
==> default: Thank you for installing Chef!


And further down the log, there is a data bag exception


=> default: [2015-01-28T05:29:38+00:00] DEBUG: I am not loading apt, because I have already seen it.
==> default: [2015-01-28T05:29:38+00:00] DEBUG: filtered backtrace of compile error: /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/libraries/sensu_helpers.rb:39:in `data_bag_item',/tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/recipes/default.rb:66:in `from_file'
==> default: [2015-01-28T05:29:38+00:00] DEBUG: filtered backtrace of compile error: /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/libraries/sensu_helpers.rb:39:in `data_bag_item',/tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/recipes/default.rb:66:in `from_file'
==> default: [2015-01-28T05:29:38+00:00] DEBUG: backtrace entry for compile error: '/tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/libraries/sensu_helpers.rb:39:in `data_bag_item''
==> default: [2015-01-28T05:29:38+00:00] DEBUG: Line number of compile error: '39'
==> default:
==> default: ================================================================================
==> default: Recipe Compile Error in /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/recipes/default.rb
==> default: ================================================================================
==> default:
==> default:
==> default: Chef::Exceptions::InvalidDataBagPath
==> default: ------------------------------------
==> default: Data bag path '/tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/data_bags' is invalid
==> default:
==> default: Cookbook Trace:
==> default: ---------------
==> default:   /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/libraries/sensu_helpers.rb:39:in `data_bag_item'
==> default:   /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/recipes/default.rb:66:in `from_file'
==> default:
==> default: Relevant File Content:
==> default: ----------------------
==> default: /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/libraries/sensu_helpers.rb:
==> default:
==> default:  32:            "/opt/sensu/embedded/bin/gem"
==> default:  33:          else
==> default:  34:            "gem"
==> default:  35:          end
==> default:  36:        end
==> default:  37:
==> default:  38:        def data_bag_item(item, missing_ok=false)
==> default:  39>>         raw_hash = Chef::DataBagItem.load("sensu", item)
==> default:  40:          encrypted = raw_hash.detect do |key, value|
==> default:  41:            if value.is_a?(Hash)
==> default:  42:              value.has_key?("encrypted_data")
==> default:
==> default:  43:            end
==> default:  44:          end
==> default:  45:          if encrypted
==> default:  46:            secret = Chef::EncryptedDataBagItem.load_secret
==> default:  47:            Chef::EncryptedDataBagItem.new(raw_hash, secret)
==> default:  48:          else
==> default:
==> default:
==> default: [2015-01-28T05:29:38+00:00] DEBUG: Re-raising exception: Chef::Exceptions::InvalidDataBagPath - Data bag path '/tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/data_bags' is invalid
==> default: /opt/chef/embedded/apps/chef/lib/chef/data_bag.rb:116:in `block in load'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/data_bag.rb:114:in `each'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/data_bag.rb:114:in `load'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/data_bag_item.rb:146:in `load'
==> default:   /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/libraries/sensu_helpers.rb:39:in `data_bag_item'
==> default:   /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/recipes/default.rb:66:in `from_file'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/mixin/from_file.rb:30:in `instance_eval'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/mixin/from_file.rb:30:in `from_file'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/cookbook_version.rb:245:in `load_recipe'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/run_context.rb:169:in `load_recipe'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:140:in `block in compile_recipes'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `each'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:138:in `compile_recipes'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/run_context/cookbook_compiler.rb:75:in `compile'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/run_context.rb:92:in `load'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/policy_builder/expand_node_object.rb:73:in `setup_run_context'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/client.rb:235:in `setup_run_context'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/client.rb:397:in `run'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application.rb:261:in `block in fork_chef_client'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application.rb:249:in `fork'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application.rb:249:in `fork_chef_client'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application.rb:215:in `block in run_chef_client'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in `with_server_connectivity'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application.rb:201:in `run_chef_client'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:245:in `block in interval_run_chef_client'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:234:in `loop'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:234:in `interval_run_chef_client'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:224:in `run_application'
==> default:   /opt/chef/embedded/apps/chef/lib/chef/application.rb:58:in `run'
==> default:   /opt/chef/embedded/apps/chef/bin/chef-solo:25:in `<top (required)>'
==> default:   /usr/bin/chef-solo:40:in `load'
==> default:   /usr/bin/chef-solo:40:in `<main>'

I checked the code at line 66 in /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/cookbooks/sensu/recipes/default.rb

ssl = Sensu::Helpers.data_bag_item("ssl")

In my host PC data_bags path, the file ssl.json is present. 

$ tree data_bags/
data_bags/
└── sensu
    └── ssl.json

I did not encrypt the ssl.json

I 'vargant ssh' to the guest OS and checked the data bag path. Here is the result:

:~$ sudo ls -l /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/data_bags
ls: cannot access /tmp/vagrant-chef/ee2283bdbc846a6f570f99e61af9abd4/data_bags: No such file or directory


It seems like chef-zero failed to create the data bag path in the guest OS? How can I fix it?



Cheers, Tony









  • [chef] Chef-zero and invalid sensu data-bag, Anthony Kong, 01/27/2015

Archive powered by MHonArc 2.6.16.

§