https://github.com/ansible-collections/vmware.vmware_rest/blob/main/docs/vmware.vmware_rest.vcenter_vmtemplate_libraryitems_module.rst


  *   Creates a library item in content library from a virtual machine. This 
{@term<mailto:%7B@term> operation} creates a library item in content library 
whose content is a virtual machine template created from the source virtual 
machine, using the supplied create specification. The virtual machine template 
is stored in a newly created library item.

According to the documentation the 
vmware.vmware_rest.vcenter_vmtemplate_libraryitems<https://github.com/ansible-collections/vmware.vmware_rest/blob/main/docs/vmware.vmware_rest.vcenter_vmtemplate_libraryitems_module.rst>
 module creates a library item in the content library. It does NOT create a new 
VM.

If you want to create a new VM I think you need to use the 
vmware.vmware_rest.vcenter_vm<https://github.com/ansible-collections/vmware.vmware_rest/blob/main/docs/vmware.vmware_rest.vcenter_vm_module.rst>
 module with state 'clone' and source of the library item you want to use to 
create the new VM.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Apr 20, 2023, at 4:03 AM, shane cummins <shane...@gmail.com> wrote:

Hi all after recently changing over from AWX to AAP and changing from the 
community.VMware collection to VMware.rest collection.
I am running into some issues when deploying I am using the module,
VMware.vmware_rest.content_library_item_info:
deploying the VM from a template in the content library,
I am able to deploy the VM from the template without any problems,
using the below playbook.
but the issue I have is the newly deployed VM keeps the name of the,
name of the template the VM was created from and does not change the name at 
guest level,
just changes on the label of the VM.


---
- name: Deploy a VM from a library "Linux_Templates"
  hosts: localhost
  gather_facts: yes

  vars:
    hostname: "{{ lookup('env', 'VMWARE_HOST') }}"                 # vCenter 
Server hostname or IP address
    username: "{{ lookup('env', 'VMWARE_USER') }}"                 # vCenter 
Server username
    password: "{{ lookup('env', 'VMWARE_PASSWORD') }}"             # vCenter 
Server password
    vm_name: "{{new_name}}"                                        # Name to 
give to the new VM
    esxi_hostname: "esx node name"                      #ESX node name
    datastore: "datastore name"                                          # Name 
of the datastore to use
    cluster_ID: "cluster name"                                       # Cluster 
name
    folder_path: "folder path name"                                   # Name of 
the folder to place the new VM in
    content_library: "content library id"
    library_item: "item id"
    AD_Domain: "domain name"                                       # Domain name
    AD_Domain_alt: "alt domain name"                                   # 
Alternative domain name
    sudo_users: "{{sudo_user_add}}"                                # Sudo users 
to add to vm


  tasks:

    - name: get the list of items of the NFS library
      vmware.vmware_rest.content_library_item_info:
        vcenter_hostname: "{{hostname}}"
        vcenter_username: "{{username}}"
vcenter_password: "{{password}}"
        library_id: "{{content_library}}"
        library_item_id: "{{library_item}}"
      register: content_library_result

    - name: Create a new VM based on the template
      vmware.vmware_rest.vcenter_vmtemplate_libraryitems:
        vcenter_hostname: "{{hostname}}"
        vcenter_username: "{{username}}"
vcenter_password: "{{password}}"
        name: "{{vm_name}}"
        vcenter_validate_certs: false
        library: "{{content_library}}"
        template_library_item: "{{library_item}}"
        placement:
          cluster: "{{cluster_ID}}"
          folder:  "{{folder_path}}"
          #resource_pool:  "{{ lookup('vmware.vmware_rest.resource_pool_moid', 
'/my_dc/host/my_cluster/Resources')}}"
        state: deploy
        powered_on: True
      register: my_new_vm

    - name: Pause for 1 minutes for server to boot up
      ansible.builtin.pause:
        seconds: 30

also when using the community collection i was able to just also add a task you 
use bash shell,
after VM was deployed in the same playbook like below
- name: "Join the VM to the Domain"
      shell: |
         timeout 60s echo '{{vcenter_password}}' | sudo realm join --verbose 
exsample.COM -U 'user' --install=/ any help would be appreciated here

thanks
Shane


--
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+unsubscr...@googlegroups.com<mailto:ansible-project+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d737ed35-b86d-4f9e-b55c-b1ca2e486f33n%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/d737ed35-b86d-4f9e-b55c-b1ca2e486f33n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/495A8C64-655B-4DA9-AB70-70A0298149FA%40nist.gov.

Reply via email to