windowschef-infrawindows-server-2012system-administration

Chef is unable to find encrypted_data_bag_secret on Windows


I am unable to load secrets from my encrypted data bag on Windows. I have copied the file to c:\chef\encrypted_data_bag_secret, which is the default path.

I first tried this:

credentials = Chef::EncryptedDataBagItem.load("system", "deploy")

This failed with this error:

10.0.1.20 [2014-09-12T19:51:45+00:00] FATAL: ArgumentError: No secret specified to load_secret and no secret found at C:\chef\encrypted_data_bag_secret

I then attempted to specify it explicitly:

secret = Chef::EncryptedDataBagItem.load_secret("c:/chef/encrypted_data_bag_secret")
credentials = Chef::EncryptedDataBagItem.load("system", "deploy", secret)

This also failed:

10.0.1.20 [2014-09-12T19:53:18+00:00] FATAL: Errno::ENOENT: No such file or directory - file not found 'c:/chef/encrypted_data_bag_secret'

Finally, I tried specifying backslashes in case this didn't work:

secret = Chef::EncryptedDataBagItem.load_secret("c:\\chef\\encrypted_data_bag_secret")
credentials = Chef::EncryptedDataBagItem.load("system", "deploy", secret)

And that also failed:

10.0.1.20 [2014-09-12T19:54:49+00:00] FATAL: Errno::ENOENT: No such file or directory - file not found 'c:\chef\encrypted_data_bag_secret'

I've tried also editing the permissions so everyone can view the encrypted_data_bag_secret file but this had no effect. Surely there is something very obvious I'm missing here.

I am running chef-client as an administrator.


Solution

  • I created a text file to contain the secret over an RDP session, but forgot that the default in Windows Explorer is to not show the file extension. Once I renamed the file to have the correct name and extension, it started working as expected.