# Identifying IOS and NXOS

**URL:** <https://forum.ansible.com/t/identifying-ios-and-nxos/35447>\
**Category:** Ansible Project\
**Created:** [July 1, 2021, 10:25am UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447 "2021-07-01T10:25:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [July 1, 2021, 10:25am UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/1 "2021-07-01T10:25:43Z")

</div>

Hi Team,

I have 100 devices in host file, both IOS and NXOS mixed. I am trying pull OS details and hostname as report. Since IOS and NXOS devices are mixed in inventory, How can IOS\_facts and NXOS\_facts work in single playbook when there is no group in inventory.

I have only one group in inventory(both IOS and NXOS)

[cisco\_devices]  
rrtr1\_ios  
n9k\_nexus

Thanks,  
Raj

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [July 3, 2021, 8:42am UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/2 "2021-07-03T08:42:41Z")

</div>

Any help would be appreciated

---

<div class="post-metadata">

**Author:** ![Jason](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jason/32/304_2.png) [@Jason](https://forum.ansible.com/u/Jason)\
**Post date:** [July 4, 2021, 11:19pm UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/3 "2021-07-04T23:19:30Z")

</div>

Well I assume you must have ansible\_network\_os variable for the hosts. So you would just need to make 2 tasks, one for ios and one for nexus.

Then create a when statement

when: ansible\_network\_os is “ios”

Same for the nexus task just change it too nexus

You put the when statement at the task level.

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [July 5, 2021, 1:27am UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/4 "2021-07-05T01:27:09Z")

</div>

I have only one group in inventory file which has IOS and NXOS devices mixed, I can only set ansible\_network\_os variable as ‘IOS’

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [July 6, 2021, 10:42am UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/5 "2021-07-06T10:42:26Z")

</div>

Is there any solution for this?

---

<div class="post-metadata">

**Author:** ![Nilashish\_Chakrabort](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@Nilashish\_Chakrabort](https://forum.ansible.com/u/Nilashish_Chakrabort)\
**Post date:** [July 29, 2021, 3:44pm UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/6 "2021-07-29T15:44:04Z")

</div>

Hello,

I don’t think this is possible to achieve if you can _only_ set `ansible_network_os` to `ios`. The \*\_facts (or any network module with `connection: network_cli`) is dependent on the correct cliconf and terminal plugins being loaded which is identified by `ansible_network_os` value.

Thanks.

---

<div class="post-metadata">

**Author:** ![Nilashish\_Chakrabort](https://avatars.discourse-cdn.com/v4/letter/n/f475e1/32.png) [@Nilashish\_Chakrabort](https://forum.ansible.com/u/Nilashish_Chakrabort)\
**Post date:** [July 29, 2021, 5:40pm UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/7 "2021-07-29T17:40:55Z")

</div>

Since your target devices are restricted to IOS and NX-OS which share similarities in CLI structure, you can possibly do something like the following. However, this is not recommended at all and is not guaranteed to work. The correct approach is to fix your inventory and group the target hosts properly.

---

<div class="post-metadata">

**Author:** ![Pushparaj\_Gothandam](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pushparaj_gothandam/32/5538_2.png) [@Pushparaj\_Gothandam](https://forum.ansible.com/u/Pushparaj_Gothandam)\
**Post date:** [July 30, 2021, 6:28am UTC](https://forum.ansible.com/t/identifying-ios-and-nxos/35447/8 "2021-07-30T06:28:35Z")

</div>

Thank you … Awesome !
