# Variables in dynamic inventory not working

**URL:** <https://forum.ansible.com/t/variables-in-dynamic-inventory-not-working/7703>\
**Category:** Get Help\
**Tags:** netbox\
**Created:** [August 7, 2024, 7:50am UTC](https://forum.ansible.com/t/variables-in-dynamic-inventory-not-working/7703 "2024-08-07T07:50:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shb256](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shb256/32/2535_2.png) [@shb256](https://forum.ansible.com/u/shb256)\
**Post date:** [August 7, 2024, 7:50am UTC](https://forum.ansible.com/t/variables-in-dynamic-inventory-not-working/7703/1 "2024-08-07T07:50:09Z")

</div>

Hi,  
i ve setup an playbook with cli\_command  
I ve a static inventory

> 192.168.200.159 ansible\_network\_os=ios ansible\_ssh\_user=user ansible\_connection=network\_cli

everything is working as expected, and executed on a cisco switch

now i ve changed the inventory to dynamic netbox inventory

> * * *
> 
> plugin: netbox.netbox.nb\_inventory  
> validate\_certs: False  
> config\_context: True  
> compose:  
> ansible\_network\_os: ios  
> ansible\_ssh\_user: user  
> ansible\_connection: network\_cli

now i got this error when it tries to connect

> “msg”: “Connection type ssh is not valid for this module”

it looks like that my variables are not used in dynamic invnetory  
I ve tried to add the variables to ansible.cfg  
and I ve tried to add the variables to netbox context

Maybe someone can point me the right direction

thanks

---

<div class="post-metadata">

**Author:** ![binbashroot](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@binbashroot](https://forum.ansible.com/u/binbashroot)\
**Post date:** [August 7, 2024, 12:28pm UTC](https://forum.ansible.com/t/variables-in-dynamic-inventory-not-working/7703/2 "2024-08-07T12:28:49Z")

</div>

Using compose with strings needs a little bit more than just treating it as a regular ansible variable

As an example try using:

```auto
compose:
     ansible_network_os: "'ios'" 

```

You’ll need to do this for all of your compose vars.

---

<div class="post-metadata">

**Author:** ![shb256](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shb256/32/2535_2.png) [@shb256](https://forum.ansible.com/u/shb256)\
**Post date:** [August 7, 2024, 4:27pm UTC](https://forum.ansible.com/t/variables-in-dynamic-inventory-not-working/7703/3 "2024-08-07T16:27:43Z")

</div>

Thanks you very much

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [September 6, 2024, 4:28pm UTC](https://forum.ansible.com/t/variables-in-dynamic-inventory-not-working/7703/4 "2024-09-06T16:28:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
