Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_guest: Cloning with disk customization fails #57817

Closed
ralphie02 opened this issue Jun 14, 2019 · 7 comments
Closed

vmware_guest: Cloning with disk customization fails #57817

ralphie02 opened this issue Jun 14, 2019 · 7 comments
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community

Comments

@ralphie02
Copy link

ralphie02 commented Jun 14, 2019

SUMMARY

Cloning from a template that has disk set to non-persistent fails when the disk for the new machine is set to persistent.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_guest

ANSIBLE VERSION
ansible 2.8.0
  config file = /home/ralphie02/.ansible.cfg
  configured module search path = [u'/home/ralphie02/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]
CONFIGURATION
ANSIBLE_NOCOWS(/home/ralphie02/.ansible.cfg) = True
ANSIBLE_PIPELINING(/home/ralphie02/.ansible.cfg) = True
ANSIBLE_SSH_ARGS(/home/ralphie02/.ansible.cfg) = -C -o ControlMaster=auto -o ControlPersist=1800s
ANSIBLE_SSH_CONTROL_PATH(/home/ralphie02/.ansible.cfg) = /tmp/ansible-ssh-%%h:%%p-%%r
COLOR_VERBOSE(/home/ralphie02/.ansible.cfg) = bright blue
DEFAULT_CALLBACK_WHITELIST(/home/ralphie02/.ansible.cfg) = [u'profile_tasks', u'log_plays_capture', u'actionable', u'skippy', u'task_timer', u'vers
DEFAULT_FORKS(/home/ralphie02/.ansible.cfg) = 20
DEFAULT_HASH_BEHAVIOUR(/home/ralphie02/.ansible.cfg) = merge
DEFAULT_HOST_LIST(/home/ralphie02/.ansible.cfg) = [u'/home/ralphie02/Shared/Ansible/staging']
DEFAULT_REMOTE_USER(/home/ralphie02/.ansible.cfg) = razucena
DEFAULT_ROLES_PATH(/home/ralphie02/.ansible.cfg) = [u'/home/ralphie02/Shared/Ansible/roles']
DEFAULT_TIMEOUT(/home/ralphie02/.ansible.cfg) = 30
DEFAULT_VAULT_PASSWORD_FILE(/home/ralphie02/.ansible.cfg) = /home/ralphie02/ansible-vault-key
INJECT_FACTS_AS_VARS(/home/ralphie02/.ansible.cfg) = False
RETRY_FILES_ENABLED(/home/ralphie02/.ansible.cfg) = False
OS / ENVIRONMENT

Target:
debian 7,8,9
centos 6,7

Controlled:
debian 9

STEPS TO REPRODUCE

Step 1:
Set a machine/template's disk to non-persistent
Step 2:
Create machine wish disk set to persistent

- hosts: localhost
  gather_facts: no

- vmware_guest:
    hostname: my_hostname
    datacenter: my_datacenter
    name: test-vm
    user: my_user
    pass: my_pass
    esxi_hostname: my_esxi_hostname
    folder: my_folder
    template: template_of_machine_with_non_persistent_vdisk
    hardware: my_hardware
    disk:
    - { size_gb: 200, type: thin, datastore: my_datastore, disk_mode: persistent }
    networks: []
    state: poweredon
    validate_certs: no
    wait_for_ip_address: yes
EXPECTED RESULTS

Machine created without issues

ACTUAL RESULTS

task fails with the following message below

"msg": "Failed to create a virtual machine : Cannot complete the operation because the file or folder /vmfs/volumes/5751fd49-060f2861-6489-1c98ec2b9b94/test-vm/test-vm.vmdk already exists"

This used to work perfectly fine before 2.8.0.
I didn't see any major changes as per the changelog concerning vmware_guest/disk but I did find these commits: 8eff4ca and 7c8b5a4
These are the only commits I found regarding disks/2.8 that might be causing this.

@ralphie02
Copy link
Author

ralphie02 commented Jun 14, 2019

Current workaround is changing the template's disk from non-persistent to persistent THEN cloning it.
To me this seems like a regression bug since it used to work fine in ansible 2.7.8 at least.

Edit: mentioned that it used to work on 2.7

@ansibot
Copy link
Contributor

ansibot commented Jun 14, 2019

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Jun 14, 2019
@Akasurde Akasurde removed the needs_triage Needs a first human triage before being processed. label Jun 14, 2019
@Tomorrow9
Copy link
Contributor

I'll try to reproduce this issue in my env if there is no one else working on it. Thanks.

@m3300b
Copy link

m3300b commented Jul 3, 2019

getting similar behavior, though without specifying persistent disk_mode for cloned vm.
with ansible 2.7.8, cloning from template and disk resize works like a charm.

with the below it fails with:
" Failed to create a virtual machine : Cannot complete the operation because the file or folder /vmfs/XXX.vmdk already exists"

ansible 2.8.1 config file = /home/matm300b/work/talend/ansible.cfg configured module search path = ['/home/matm300b/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/matm300b/work/python/lib/python3.7/site-packages/ansible executable location = /home/matm300b/work/python/bin/ansible python version = 3.7.3 (default, May 11 2019, 00:38:04) [GCC 9.1.1 20190503 (Red Hat 9.1.1-1)]
AND
pyvmomi 6.7.1

@m3300b
Copy link

m3300b commented Jul 3, 2019

removing the fileOperation seems to do the trick under Asnible 2.8.1 vmware_guest.py:

@@ -1805,7 +1805,7 @@
                 continue
             elif vm_obj is None or self.params['template']:
                 # We are creating new VM or from Template
-                diskspec.fileOperation = vim.vm.device.VirtualDeviceSpec.FileOperation.create
+                pass

             # which datastore?
             if expected_disk_spec.get('datastore'):

@Akasurde
Copy link
Member

resolved_by_pr #58737

@Akasurde
Copy link
Member

Closing this issue as PR #58737 is merged. If issue persists, please feel free to open a new issue.

@ansible ansible locked and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
5 participants