例如,我想在"管理员桌面"下面克隆一个虚拟机。如下图所示: Click here to see the image
以下脚本是从指定模板克隆VM并将VM放入指定文件夹。但是当VCenter服务器上不存在该文件夹时失败:
--- - hosts: localhost connection: local sudo: false user: root gather_facts: false serial: 1 vars_files: - createVmVars.yml tasks: - name: Deploying VM from template. vsphere_guest: vcenter_hostname: "{{vcenter_hostname}}" username: "{{vcenter_username}}" password: "{{vcenter_password}}" guest: "{{guest_name}}" from_template: yes template_src: "{{template_src}}" cluster: "{{cluster}}" resource_pool: "{{resource_pool}}" vm_extra_config: folder: "{{folder_name}}"
需要帮助才能使此脚本具有灵活性,以便在该文件夹不存在时,应该创建所提到的文件夹,然后在此文件夹下克隆VM。