[chef] Chefspec and accessing a node attribute within EncryptedDataBagItem.load


Chronological Thread 
  • From: Bryan Bishop < >
  • To:
  • Subject: [chef] Chefspec and accessing a node attribute within EncryptedDataBagItem.load
  • Date: Fri, 7 Feb 2014 11:19:02 -0600

Hello great chefs!

I'm running into trouble using ChefSpec 3.2.0 and converging a
ChefSpec runner with an encrypted data bag.  The data bag I'm trying
to load is referenced by a node attribute, like this:


    mysql_passwords =
Chef::EncryptedDataBagItem.load(node['percona']['encrypted_data_bag'],
"mysql")


So in my ChefSpec runner, I've set that node attribute:

    let(:chef_run) do
      ChefSpec::Runner.new do |node|
        node.override["percona"]["encrypted_data_bag"] = 'something'
      end.converge(described_recipe)
    end

But converging the ChefSpec running seems to choke on this.  Are these
attributes not being assigned in the Runner object?  I've placed a
puts statement in my recipe code and the tests print out the correct
bogus attribute I defined, "something."

  4>> mysql_passwords =
Chef::EncryptedDataBagItem.load(node['percona']['encrypted_data_bag'],
"mysql")

Failures:

  1) prsn_epen2::_deploy_common does something
     Failure/Error: end.converge(described_recipe)
     TypeError:
       no implicit conversion of Array into String


I'm sure this is something obvious, can anyone help me please?  I
really appreciate the discussions on this list!



- Bryan



Archive powered by MHonArc 2.6.16.

§