# Run once on multiple Inventory Hosts with same ansible\_host value

**URL:** <https://forum.ansible.com/t/run-once-on-multiple-inventory-hosts-with-same-ansible-host-value/38515>\
**Category:** Ansible Project\
**Created:** [October 11, 2023, 7:46pm UTC](https://forum.ansible.com/t/run-once-on-multiple-inventory-hosts-with-same-ansible-host-value/38515 "2023-10-11T19:46:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [October 11, 2023, 7:46pm UTC](https://forum.ansible.com/t/run-once-on-multiple-inventory-hosts-with-same-ansible-host-value/38515/1 "2023-10-11T19:46:24Z")

</div>

I am importing my inventory from ServiceNow, so I have to go with what I’m given. I’m given multiple WebLogic Nodes per individual server, that is per ansible\_host. I’d like the user to be able to pull all Inventory Hosts, but have the process run once per “ansible\_host” sometimes and other times have the process run against each Inventory Host separately, so multiple times per ansible\_host.

Is this possible without writing a “lock file” solution?

Thank you.

---

<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:** [October 11, 2023, 8:20pm UTC](https://forum.ansible.com/t/run-once-on-multiple-inventory-hosts-with-same-ansible-host-value/38515/2 "2023-10-11T20:20:01Z")

</div>

No need for lockfiles, I would use groups instead. Setup a group that  
has one instance of inventory\_hostname per ansible\_host, then target  
that group when you want to do 'single operation per real host'. for  
'all' just use the all group.

---

<div class="post-metadata">

**Author:** ![Kevin\_Knox](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kevin_knox/32/3926_2.png) [@Kevin\_Knox](https://forum.ansible.com/u/Kevin_Knox)\
**Post date:** [October 11, 2023, 11:14pm UTC](https://forum.ansible.com/t/run-once-on-multiple-inventory-hosts-with-same-ansible-host-value/38515/3 "2023-10-11T23:14:46Z")

</div>

Lovely idea! Thank you!

Kevin
