Using databag in recipe


#1

Hello experts,

I have a databag named "os" and here is the structure of it.

{
"id": "config",
"6.3": {
"ver": "6.3.00",
"kernel": "2.6.32-279.el6.x86_64",
"date": "2012-11"
},
"6.6": {
"ver": "6.6.00",
"kernel": "2.6.32-504.el6.x86_64",
"date": "2015-06"
},
"6.8": {
"ver": "6.8.00",
"kernel": "2.6.32-642.15.1.el6.x86_64",
"date": "2017-03"
}
}

I am trying to acheive following things.

If a node kernel matches with databag kernel it append a file with following information. For example on a given node if the installed kernel is 2.6.32-504.el6.x86_64 than,
following line will be added to the file.

ver=6.6.00_2015-06,2.6.32-504.el6.x86_64

If installed kernel didn't match with kernels in the databag, the file will be appened as below

ver=6.6.00_2015-06,unknown

Thanks