I have templates with variables. these variables are in databags and and depend on the environment. Example:
# Template
address =$foo
# Environment:
develoment
# Databag:
$foo = "sdfsdf"
How do I combine all of that?, I don't know where to put the information.
In template
address = "Http://ffff/dfg/"
I need to put here a variable
address = $pepe
In my databag in have the following data depending on the environment:
$pepe = "Http://ffff/dfg/"
$pepep ="Http://ffff/dewrwerw/
I don't know what I should write in the recipe.
Template:
address = <%= @pepe %>
Databag:
{
"_default": {
"pepe": "Http://ffff/dfg/"
},
"staging": {
"pepe": "Http://ffff/staging"
},
"production": {
"pepe": "Http://ffff/prod"
}
}
Recipe:
data = data_bag_item( 'databagname', 'itemname' )
template '/path/to/file' do
variables( pepe: data[node.chef_environment]['pepe'] )
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With