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

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

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.

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.

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
  vmware_module:
    regular_module_args
  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.

Create a local, temporary file of the new hosts and environment variable ANSIBLE_INVENTORY?

Mike