I m trying to search my databag from the recipe using below method.
My databag is like:
then in recipe:
cq = search(:data_bag, 'id: "abc"')
then i m grabbing the corresponding ip address.
puts cq['value'] and I get the proper data i.e. 220.127.116.11 which is what I am looking for.
But I have a requirement wherein abc id is in a variable and I want to search using that variable in the databag file. something like below but it doesnt work. I tried using escape character(might be something wrong there) but nothing works. Could anyone please guide me on how can I achieve this? I just want to understand on how can i search the value using a variable but not hardcoding it in the command search(.....)
My variable : node.run_state['datacentre']
cq = search(:data_bag, 'id: "node.run_state['datacentre']"')