# Migrating to Ansible v2.0 API --\> What is this Options namedtuple?

**URL:** <https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755>\
**Category:** Ansible Developer\
**Created:** [June 13, 2016, 5:27pm UTC](https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755 "2016-06-13T17:27:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fran\_Fitzpatrick](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@Fran\_Fitzpatrick](https://forum.ansible.com/u/Fran_Fitzpatrick)\
**Post date:** [June 13, 2016, 5:27pm UTC](https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755/1 "2016-06-13T17:27:00Z")

</div>

Hi all,

We’re currently upgrading our system to the new Ansible v2.x API and while I understand that the API is not officially supported, I’m trying to understand how to use the `options` named tuple that appears to be popping up everywhere. In v1.9, we had passed all of our configuration information to ansible using extra\_vars (such as ansible\_connection, as well as some other configuration parameters)… Did these options take the place of that?

Thanks,  
Fran

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [June 13, 2016, 6:03pm UTC](https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755/2 "2016-06-13T18:03:59Z")

</div>

They are complementary, the Options tuple is simulating ‘command line options’, which still get overridden by connection variables.

---

<div class="post-metadata">

**Author:** ![Fran\_Fitzpatrick](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@Fran\_Fitzpatrick](https://forum.ansible.com/u/Fran_Fitzpatrick)\
**Post date:** [June 13, 2016, 6:51pm UTC](https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755/3 "2016-06-13T18:51:42Z")

</div>

Thanks, Brian.

So right now I’m essentially following this guide: [http://docs.ansible.com/ansible/developing\_api.html](http://docs.ansible.com/ansible/developing_api.html)

Since we have all of our configuration options being passed in as variables, I essentially do `variable_manager.extra_args = our_extra_args` … since I have that, I’m not sure why I need to create an Options tuple and pass it into the TaskQueueManager? Then it seems like I would need to do, for example: options.connect = out\_extra\_args[‘ansible\_connection’]?

I feel like I’m missing something here.

Fran

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 13, 2016, 7:01pm UTC](https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755/4 "2016-06-13T19:01:32Z")

</div>

The API wasn’t really designed to work outside of the context of the ansible CLI utilities (or at least that wasn’t a primary concern). As such, TaskQueueManager expects you to pass in something that works like an optparse options object.

The example uses a named tuple, as that is easiest. The items in that documentation for namedtuple are the minimum required to satisfy the API. Any settings outside of what is mentioned in that namedtuple can be passed via other means.

Since you have mentioned you use extra\_vars to pass in things like connection, you would just need to mimic the defaults of the options in optparse for the ansible clis. extra\_vars would then override it.

So something like:

options = Options(connection=‘ssh’, …)  
extra\_vars = dict(ansible\_connection=winrm, …)

Hope that makes sense, basically you have to give an options that satisfies the API (What the code is expecting). If you override via extra\_vars, then so be it, but you still need to supply, even if different, those options in the options namedtuple.

---

<div class="post-metadata">

**Author:** ![Fran\_Fitzpatrick](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@Fran\_Fitzpatrick](https://forum.ansible.com/u/Fran_Fitzpatrick)\
**Post date:** [June 14, 2016, 2:11pm UTC](https://forum.ansible.com/t/migrating-to-ansible-v2-0-api-what-is-this-options-namedtuple/21755/5 "2016-06-14T14:11:29Z")

</div>

Thanks, guys! Got everything working! 😃
