I was wondering it it was possible to write to a data bag from within a
recipe?
I know this is not the main purpose of a data bag but sometimes I need to
exchange data between several nodes. I sure can put that data in myself but
it’d be better if fully automated.

I was wondering it it was possible to write to a data bag from within a recipe?
I know this is not the main purpose of a data bag but sometimes I need to exchange data between several nodes. I sure can put that data in myself but it’d be better if fully automated.

I was wondering it it was possible to write to a data bag from within a
recipe?
I know this is not the main purpose of a data bag but sometimes I need to
exchange data between several nodes. I sure can put that data in myself but
it’d be better if fully automated.

I was wondering it it was possible to write to a data bag from within a
recipe?
I know this is not the main purpose of a data bag but sometimes I need to
exchange data between several nodes. I sure can put that data in myself but
it’d be better if fully automated.

My use case here is to store passwords generated on the node to be used by
other nodes. We have separated environment for each client with dedicated
databags and encryption key so I wanted to leverage this to avoid having
the password in plaintext in the node’s attribute.

I was wondering it it was possible to write to a data bag from within a
recipe?
I know this is not the main purpose of a data bag but sometimes I need to
exchange data between several nodes. I sure can put that data in myself but
it’d be better if fully automated.

I did something like this for managing RunDeck SSH key pairs and I can
testify that it does, in fact, work. Data bag items have a couple of
tricks to them but the documentation sorted me out. Due to the way
encrypted data bag items are handled, you have to do a few things
differently if you’re generating one – essentially, you create a data bag
item first, then pass in the encrypted data bag item as payload. Then you
call #save on the containing data bag item and you’re all set.

If you aren’t already writing these as library functions, I’d suggest doing
that for the cookbook. It does make your recipe a bit more readable …
and, of course, once you’re writing pure Ruby in your library you can
document it like any other Ruby code.

My use case here is to store passwords generated on the node to be used by
other nodes. We have separated environment for each client with dedicated
databags and encryption key so I wanted to leverage this to avoid having
the password in plaintext in the node’s attribute.

I was wondering it it was possible to write to a data bag from within a
recipe?
I know this is not the main purpose of a data bag but sometimes I need
to exchange data between several nodes. I sure can put that data in myself
but it’d be better if fully automated.

You can simply store an encrypted version of the password in the node’s
attributes. You can use the normal Ruby OpenSSL stdlib to do the encryption
(the encrypted data-bag code does that under the hood).

You can even use the encrypted-data-bag key for this purpose, provided the
key management procedures are appropriate.

You do not need to write to encrypted data-bag items from within recipes.