# Creating VM from Template is Failing

**URL:** <https://forum.ansible.com/t/creating-vm-from-template-is-failing/27596>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [May 23, 2018, 4:09am UTC](https://forum.ansible.com/t/creating-vm-from-template-is-failing/27596 "2018-05-23T04:09:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gowtham\_Nakulan](https://avatars.discourse-cdn.com/v4/letter/g/90db22/32.png) [@Gowtham\_Nakulan](https://forum.ansible.com/u/Gowtham_Nakulan)\
**Post date:** [May 23, 2018, 4:09am UTC](https://forum.ansible.com/t/creating-vm-from-template-is-failing/27596/1 "2018-05-23T04:09:59Z")

</div>

##### SUMMARY

We are trying to create VM from template.  
I am facing issue at assigning ip line.

##### ISSUE TYPE- Documentation Report

##### COMPONENT NAME

vsphere\_guest:

##### ANSIBLE VERSION

```auto
ansible 2.5.2

```

##### CONFIGURATION##### OS / ENVIRONMENT

Ubuntu

##### STEPS TO REPRODUCE

```auto
---

- hosts: 127.0.0.1
  connection: local
  user: root
  sudo: false
  gather_facts: false
  serial: 1

  tasks:
  - name: Importing Variables
    include_vars: main.yml
  - debug: var=hostname_var
  - debug: var=username_var
  - debug: var=password_var

  - vsphere_guest:
       vcenter_hostname: "{{hostname_var}}"
       username: "{{username_var}}"
       password: "{{password_var}}"
       guest: vmfromtemplate
       from_template: yes
       template_src: Ubuntu VM
       cluster: t1k1-cluster
    networks:
      - name: "vcesys_esx_mgmt"
         ip: "10.1.1.10"
        netmask: "255.255.255.0"
        gateway: "10.0.0.1"
    wait_for_ip_address: yes
~

```

##### EXPECTED RESULTS

VMshould be created from template and assigned the ip for the interface which i am giving at the ntework line.

##### ACTUAL RESULTS

```auto
ERROR! Syntax Error while loading YAML.
  did not find expected key

The error appears to have been in '/opt/work/ansible/playbooks/gowtham/vmfromtem plate.yml': line 27, column 10, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

      - name: "vcesys_esx_mgmt"
         ip: "10.1.1.10"
         ^ here

```

---

<div class="post-metadata">

**Author:** ![BIJAY\_PARIDA](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@BIJAY\_PARIDA](https://forum.ansible.com/u/BIJAY_PARIDA)\
**Post date:** [May 23, 2018, 10:26am UTC](https://forum.ansible.com/t/creating-vm-from-template-is-failing/27596/2 "2018-05-23T10:26:35Z")

</div>

Please check the indentation after the line “ip” - 28 and 29

-Bijay

---

<div class="post-metadata">

**Author:** ![Umesh\_Gowda](https://avatars.discourse-cdn.com/v4/letter/u/8edcca/32.png) [@Umesh\_Gowda](https://forum.ansible.com/u/Umesh_Gowda)\
**Post date:** [June 1, 2018, 4:32am UTC](https://forum.ansible.com/t/creating-vm-from-template-is-failing/27596/3 "2018-06-01T04:32:40Z")

</div>

```auto
networks:
      - name: "vcesys_esx_mgmt"
        ip: "10.1.1.10"
        netmask: "255.255.255.0"
        gateway: "10.0.0.1"

```

```auto
Try this out 

```
