Chef: Load Attributes from encrypted databag in json role
- by jcvj
I'm want to use the postfix cookbook for chef. The sasl password is expected to be in an attribute. So usually you would do this:
"default_attributes": {
"postfix": {
"sasl": {
"smtp_sasl_passwd": "somepassword"
}
}
}
The thing is: I don't want to have the password in the repository in plain text. So I put it in an encrypted data bag. Now I want to access it. This can be done with this:
Chef::EncryptedDataBagItem.load("passwords", "postfix")['password']
The problem: This only works in a .rb file, but my role is in json; all my roles are in json! I don't want to change that just for this purpose. Does anybody have an idea what to do here? Help is very appreciated.