# What is the best way to manage machines that aren't defined as hosts?

**URL:** <https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056>\
**Category:** Ansible Project\
**Tags:** vmware\
**Created:** [August 16, 2019, 4:15am UTC](https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056 "2019-08-16T04:15:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kurt\_Robinson](https://avatars.discourse-cdn.com/v4/letter/k/f475e1/32.png) [@Kurt\_Robinson](https://forum.ansible.com/u/Kurt_Robinson)\
**Post date:** [August 16, 2019, 4:15am UTC](https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056/1 "2019-08-16T04:15:33Z")

</div>

I intend to Ansible to run deployment configuration on a number of Dell ESXi hosts in VMware using VMware and OpenManage modules.

In my past ansible training, my playbooks have always run from hosts that I have defined in an inventory file. The machines I wish to configure don’t have ansible installed so they will be managed from the localhost node.

My question is, what is the best practice in running configuration tasks on these machines that aren’t actual hosts within ansible?

Currently, I am thinking of creating a csv file which will contain the host information, then loop through each host and run my tasks to run on each host using read\_csv.

pseudo:

- name: Read csv and send to task  
csv\_read: csvname.csv  
task:
- taskname  
passvar:
- csv.hostname

---

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 16, 2019, 5:34am UTC](https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056/2 "2019-08-16T05:34:43Z")

</div>

I’m not sure I understand fully, but none of the hosts you are configuring need Ansible to be installed for you make changes remotely. Instead of defining your hosts in a CSV, define your hosts as part of Ansible inventory and your tasks will loop through them naturally. You can also group hosts as you had mentioned, and run task or assign vars to specific groups, just as you had in your example. To execute a play only on remote esxi servers one way is:

- name: configure esxi hosts  
hosts: esxi-hosts  
roles:
- your roles here

If I run this play and have 5 esxi hosts in my inventory group, then this will run all roles or tasks each time for each of those 5 servers in parallel

Making use of group\_vars files and host\_vars files can change the play vars based on the group.

---

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 16, 2019, 5:36am UTC](https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056/3 "2019-08-16T05:36:31Z")

</div>

I'm not sure I understand fully, but none of the hosts you are configuring need Ansible to be installed for you make changes remotely. Instead of defining your hosts in a CSV, define your hosts as part of Ansible inventory and your tasks will loop through them naturally. You can also group hosts as you had mentioned, and run task or assign vars to specific groups, just as you had in your example. To execute a play only on remote esxi servers one way is:

- name: configure esxi hosts  
&nbsp;&nbsp;hosts: esxi-hosts  
&nbsp;&nbsp;roles:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- your roles here

If I run this play and have 5 esxi hosts in my inventory group, then this will run all roles or tasks each time for each of those 5 servers in parallel

Making use of group\_vars files and host\_vars files can change the play vars based on the group.

---

<div class="post-metadata">

**Author:** ![Zolvaring](https://avatars.discourse-cdn.com/v4/letter/z/ce73a5/32.png) [@Zolvaring](https://forum.ansible.com/u/Zolvaring)\
**Post date:** [August 16, 2019, 5:42am UTC](https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056/4 "2019-08-16T05:42:35Z")

</div>

Seeing that you may want to loop through actual guests, I would still define them as Ansible inventory hosts if you know them ahead of time, and if you need to run tasks from a different host by invoking VMware module then try:

- name: do a thing to a guest  
&nbsp;&nbsp;vmware\_module:  
&nbsp;&nbsp;&nbsp;&nbsp;regular\_module\_args  
&nbsp;&nbsp;delegate\_to: localhost (or somewhere else)

The end result will still naturally loop your inventory but will run from whichever host you delegate the commands to.

---

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [August 16, 2019, 3:45pm UTC](https://forum.ansible.com/t/what-is-the-best-way-to-manage-machines-that-arent-defined-as-hosts/31056/5 "2019-08-16T15:45:59Z")

</div>

Create a local, temporary file of the new hosts and environment variable ANSIBLE\_INVENTORY?

Mike
