Ansible Create vSphere Virtual Machine

155 views
Skip to first unread message

David Foley

unread,
Feb 17, 2020, 10:48:30 AM2/17/20
to Ansible Project
Ansible playbook fails to deploy Virtual Machine: Can't Find Folder 
How can I deploy a Virtual machine without any Folders within the Cluster ? 

---
    - name: Running Create Virtual Machine Playbook
      hosts: localhost
      gather_facts: false
      connection: local
      tasks:
        - name: Virtual Machine customization
          vmware_guest:
            validate_certs: no
            folder:  "{{ }}"
            hostname: "{{ }}"
            username:  "{{ }}"
            password:  "{{ }}"
            cluster :  "{{ }}"
            customization_spec:  "{{ }}"
            name:  "{{ }}"
            template: "{{ }}"
            state: poweredon
            disk:
              - datastore:  "{{ }}"
            networks:
            - name:  "{{ }}"
              device_type: e1000e
            customization:
              autologon: yes
            hardware:
              memory_mb: 2048
              num_cpus: 1
          delegate_to: localhost
           # wait_for_ip_address: True

Jorge Rúa

unread,
Feb 17, 2020, 10:53:13 AM2/17/20
to ansible...@googlegroups.com
Try with :
folder: "{{ yourfolder | d ('/') }}"

--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fed0cb7e-644a-4344-a18c-01cf3a87beef%40googlegroups.com.

João Santos

unread,
Feb 17, 2020, 11:05:46 AM2/17/20
to Ansible Project
Hi David

It's a good pratice that you are able to identify uniqueness of the virtual machine and folder will help you to achieve that.

You already have an answer before that might help you out to achieve what you're requesting (no folders).
Nevertheless check here https://github.com/js-max/ansible-vmware-new-vm, might help you to speed up things if need to.


Cheers

Dick Visser

unread,
Feb 17, 2020, 11:06:39 AM2/17/20
to ansible...@googlegroups.com
On Mon, 17 Feb 2020 at 16:53, Jorge Rúa <jruar...@gmail.com> wrote:
>
> Try with :
> folder: "{{ yourfolder | d ('/') }}"

For everyone else that is wondering what the 'd' filter is, it's an
alias for 'default' :)


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

David Foley

unread,
Feb 17, 2020, 12:04:55 PM2/17/20
to Ansible Project
When i Enter the virtualMachine Name _ Folder I'm getting the following 

 No Folder /TESTMACHINE match in search path.. 

David Foley

unread,
Feb 17, 2020, 2:29:04 PM2/17/20
to Ansible Project
Ok I'm using just / as the folder seems to be bypassing that now 

but not sure what could be causing the following:: fatal: [localhost -> localhost]: FAILED! => {"changed": false, "msg": "Failed to create a virtual machine : Unable to access the virtual machine configuration: Unable to access file [vsanDatastore] /win10-template.vmtx"}
Reply all
Reply to author
Forward
0 new messages