Perhaps you could show your vars_plugin?  There is the potential that it
could be run twice, depending on where you call that code from.

The 3 following methods are all run 1 time in ansible.inventory.Inventory:

plugin.get_group_vars
plugin.run
plugin.get_host_vars

Also, as a heads up, this is probably a better discussion for ansible-devel.

On Thu, Sep 11, 2014 at 10:27 AM, Guy Matz <[email protected]> wrote:

> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CABnTgtWLOnLrA0jn45n8HtDave37UDo8PbHe2JV9iU6yd5Kqrw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CABnTgtWLOnLrA0jn45n8HtDave37UDo8PbHe2JV9iU6yd5Kqrw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Matt Martz
[email protected]
http://sivel.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_R7o%2B4M_27UcTDbBHJqJcs%2B_Vi9M62K8-k7FwXo0Kq7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to