Creating VM from Template is Failing

27 views
Skip to first unread message

Gowtham Nakulan

unread,
May 23, 2018, 12:09:59 AM5/23/18
to Ansible Project
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
ansible 2.5.2
CONFIGURATION
OS / ENVIRONMENT

Ubuntu

STEPS TO REPRODUCE
---

- 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
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

BIJAY PARIDA

unread,
May 23, 2018, 6:27:28 AM5/23/18
to ansible...@googlegroups.com
Please check the indentation after the line "ip" - 28 and 29

-Bijay

--
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-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/09298fdf-b5d7-4c59-8a42-da17e31bce4d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Umesh Gowda

unread,
Jun 1, 2018, 12:32:40 AM6/1/18
to Ansible Project
networks:
      - name: "vcesys_esx_mgmt"
        ip: "10.1.1.10"
        netmask: "255.255.255.0"
        gateway: "10.0.0.1"
Try this out 
Reply all
Reply to author
Forward
0 new messages