0
votes

i'm currently working on a project, to automate VM deployment, based on template. To proceed I'm using Ansible 2.10, and Pyvmomi 7.0.1.

I'm facing an issue trying to define a Pvlan id (51), to my guest, here's my playbook :

---
- hosts: localhost
  gather_facts: no
  vars:
    vcenter_server: "100.64.31.5"
    vcenter_user: "xxxxx"
    vcenter_pass: 'xxxxxx'
    datacenter_name: "xxxxxx"
    cluster_name: "xxxxxx"
  tasks:
  - name: Clone the template
    vmware_guest:
      hostname: "{{ vcenter_server }}"
      username: "{{ vcenter_user }}"
      password: "{{ vcenter_pass }}"
      validate_certs: False
      name: NewVmName    
      template: "mytemplate"
      datacenter: "{{ datacenter_name }}"
      folder: "/vm"
      cluster: "{{ cluster_name }}"
      datastore: "SAN08T2lunHDS1"
      networks:
      - vlan: 51
        ip: 100.64.67.13
        netmask: 255.255.240.0
        type: static

But I keep getting the following error : AttributeError: 'vim.dvs.VmwareDistributedVirtualSwitch.PvlanSpec' object has no attribute 'vlanId'

I already checked my user permissions on Vswitch, Datastore an VM, nothing to declare on this side.

1
Since I don't see anything else relating to the variable in your error, I suspect this is a problem related to "mytemplate". This pretty much looks like a problem for superuser.com rather that SO. But before your transfer your question therer, you should add much more debugging info, more specifically a debug view of vim.dvs.VmwareDistributedVirtualSwitch.PvlanSpec, where it is declared and precisely it is used because there is not a single clue about that in your post.Zeitounator

1 Answers

0
votes

Ok, just found out how to proceed, instead of using the vlan ID, you should use the Port Group Name.

To proceed, once connected to your Vcenter :

  1. Click Networking in the VMware Host Client inventory and click Port groups. (Or Ctrl + Shift + N)
  2. Right click on your vlan => Update settings
  3. The Port Group Name is the "name" field