Hi Mark, Quickest way to get going is probably to pass the serverlist file in to ansible using extra vars
ansible-playbook your_playbook -e @/full/path/to/your/serverlist If you don't want to use the -e (extra vars) functionality, then I think you need to use include_vars, - see http://docs.ansible.com/ansible/include_vars_module.html rather than naming the file you want to load in the vars: section of your playbook - vars is just for variables you want to declare within the playbook itself. Jon On Tuesday, 5 April 2016 15:57:39 UTC+1, Mark Matthews wrote: > > Hi Nigel / Jon > > I changed the following as suggessted: > > guest: "{{ item }}" > > What is happening now is when I run the playbook it is creating one VM in > vSphere called "files/hostnames"?? > > So its as if the playbook is looking at, with_items: "{{ serverlist }}", > and then seeing the variable, serverlist: files/hostnames, and then > creating a VM with that name. Its not looking into the 'hostnames' file and > creating the multiple VM's in that file?? > > Any ideas? > > Cheers > Mark > > On Thursday, March 10, 2016 at 5:00:18 PM UTC, Mark Matthews wrote: >> >> Hi >> >> Is it at all possible to create multiple VMware VM's using an Ansible >> playbook? Giving each VM a unique name (server1, server2, server3, server4)? >> >> I can see anyway of doing this using the following playbooks, as it keeps >> failing? >> >> --- >> - hosts: 127.0.0.1 >> connection: local >> user: root >> sudo: false >> gather_facts: false >> serial: 1 >> vars: >> vcenter_hostname: UK.server.local >> esxhost: xxx.xxx.xxx.xxx >> datastore: UK1 >> network: Web >> vmcluster: UKCLUSTER >> guest_name: server1, server2, server3, server4 >> folder: Utilities >> notes: Created by Ansible >> >> tasks: >> - name: Create VM from template >> vsphere_guest: >> vcenter_hostname: "{{ vcenter_hostname }}" >> username: "{{ username }}" >> password: "{{ password }}" >> guest: "{{ guest_name }}" >> vm_extra_config: >> notes: "{{ notes }}" >> folder: "{{ folder }}" >> from_template: yes >> template_src: "{{ vmtemplate }}" >> cluster: "{{ vmcluster }}" >> resource_pool: "/Resources" >> >> esxi: >> datacenter: UK >> hostname: "{{ esxhost }}" >> >> Any ideas or suggestions would be really appreciated. >> >> Cheers >> >> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/afbfa7e5-bdb5-4a2d-afb4-6f0061ace874%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
