- From: Bryan Bishop <
>
- To:
- Subject: [chef] Re: Re: Chefspec and accessing a node attribute within EncryptedDataBagItem.load
- Date: Fri, 7 Feb 2014 15:17:58 -0600
Thank you Pete! This has helped me on my way, I thought my problem
was the node attribute but it turned out to be stubbing the data bag.
On Fri, Feb 7, 2014 at 11:56 AM, Pete Cheslock
<
>
wrote:
>
What I think you want to do is to stub out your databag in the before block
>
so that chefspec can execute your tests on that data.
>
>
Here is an example of what I've done.
>
https://gist.github.com/petecheslock/5f6d34ff05680b2b5ec5
>
>
More info:
>
https://github.com/sethvargo/chefspec#data-bag--data-bag-item
>
>
>
On Fri, Feb 7, 2014 at 12:19 PM, Bryan Bishop
>
<
>
>
wrote:
>
>
>
> 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.