Hi! Anyone have any advice on developing a vars_plugin? This may sound kinda screwy, but for a chef -> ansible transition I need to access data from a chef data_bag in an ansible play . . . I'm able to get the chef data using pychef, but I'm having issues when trying to run the code within vars_plugin code:
import chef
def get_dbag_data():
chef_api = chef.autoconfigure()
dbag, dbag_item = 'dbag', 'dbag_item'
bag = chef.DataBag(dbag) # some debugging shows the problem is here on the second run. . !
item = bag[dbag_item]
return item.to_dict()
The code above works outside of ansible, but when run in ansible it seems to get run twice, and fails on the "bag = chef.DataBag(dbag)" line the second time around.
Any thoughts would be greatly appreciated!
Thanks!
Guy