# Passing nodenames as an argument in a command

**URL:** <https://forum.ansible.com/t/passing-nodenames-as-an-argument-in-a-command/25614>\
**Category:** Ansible Project\
**Created:** [September 27, 2017, 4:12pm UTC](https://forum.ansible.com/t/passing-nodenames-as-an-argument-in-a-command/25614 "2017-09-27T16:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parth\_Patel1](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Parth\_Patel1](https://forum.ansible.com/u/Parth_Patel1)\
**Post date:** [September 27, 2017, 4:12pm UTC](https://forum.ansible.com/t/passing-nodenames-as-an-argument-in-a-command/25614/1 "2017-09-27T16:12:36Z")

</div>

I am new to ansible. This is what I am trying to run,

on poc1 run,

client -a 8101 -h localhost ‘fabric:ensemble-add -f poc2 poc3’

I want to run above command on “poc1” node passing arguments as “poc2” and “poc3”. How do I get that using hostvars or groups from inventory file.

I have tried this but It didn’t work.

inventory file :

[testnodes]  
poc1  
poc2  
poc3

YML,

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 27, 2017, 5:04pm UTC](https://forum.ansible.com/t/passing-nodenames-as-an-argument-in-a-command/25614/2 "2017-09-27T17:04:53Z")

</div>

You are using fusehosts and not testnodes as you inverntory has.  
You can use one of these

&nbsp;&nbsp;&nbsp;{{ groups.testnodes | difference([inventory\_hostname]) | join(' ') }}"  
&nbsp;&nbsp;&nbsp;{{ groups['testnodes'][1:] | join(' ') }}

---

<div class="post-metadata">

**Author:** ![Parth\_Patel1](https://avatars.discourse-cdn.com/v4/letter/p/258eb7/32.png) [@Parth\_Patel1](https://forum.ansible.com/u/Parth_Patel1)\
**Post date:** [September 27, 2017, 5:55pm UTC](https://forum.ansible.com/t/passing-nodenames-as-an-argument-in-a-command/25614/3 "2017-09-27T17:55:23Z")

</div>

Thanks a lot ! It worked
