Searching a data bag


#1

I have created a databag called demo_databag
I then loaded up a json file as detailed below:
{“id”:“demo_value”,
“hosts”:[
{“host”:“host0.pinnacle.co.uk”, “ip”:“3.2.3.4”, “aliases”:[“host1”]},
{“host”:“host1.pinnacle.co.uk”, “ip”:“3.2.3.5”, “aliases”:[“host2”]},
{“host”:“host2.pinnacle.co.uk”, “ip”:“3.2.3.6”, “aliases”:[“host3”]},
{“host”:“host3.pinnacle.co.uk”, “ip”:“3.2.3.7”, “aliases”:[“host4”]}
]
}

In my recipe I am doing a search on the databag
I will probably use a node attribute for the search, but for the moment it is
just a string

I have tried:

allhosts = search(“demo_databag”, “id:demo_value”)

searchstring = "id:demo_value"
allhosts = search(“demo_databag”, searchstring)

allhosts = search(“demo_databag”, "demo_value)

In all cases I get a return code of 256 and the loop I have written to process
the values in the databag does not run

What am I doing wrong?