-
Notifications
You must be signed in to change notification settings - Fork 38
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
General Questions - #390
Comments
hi @luckyinva , for update or delete of VMs please check this comment and the corresponding ticket: #284 (comment) |
Currently, we have to provide UUID for update or delete ops. So post create we need to add uuid field for further management of vm. |
I wrote a sample script long time back to use vms_info and vms to avoid this manual intervention of adding uuid post creation. Note: This will only work when there are vms with unique name
---
- name: VM playbook
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <pc-ip>
nutanix_username: admin
nutanix_password: <password>
validate_certs: false
tasks:
- name: Setting Variables
set_fact:
cluster_name: "auto_cluster_prod_4f1ddb664f78"
script_path: ""
subnet_name: "vlan.800"
image_name: "alpine"
vm_name: "vm-from-ansible"
uuid: ""
- name: fetch vms with given name
ntnx_vms_info:
filter:
vm_name: "{{vm_name}}"
register: vm
- name: set uuid if vm with given name exists
set_fact:
uuid: "{{vm.response.entities[0].metadata.uuid}}"
when: vm.response.entities | length > 0
- name: create vm when uuid is not set (vm doesn't exist with given name), else update
# check_mode: yes
ntnx_vms:
state: present
vm_uuid: "{{uuid}}"
name: "{{vm_name}}"
cluster:
name: "{{cluster_name}}"
networks:
- is_connected: True
subnet:
name: "{{ subnet_name }}"
cluster:
name: "{{cluster_name}}"
disks:
- type: "DISK"
size_gb: 100
bus: "SATA"
clone_image:
name: "{{ image_name }}"
vcpus: 1
cores_per_vcpu: 1
memory_gb: 1
force_power_off: True
register: output
- name: output of vm status
debug:
msg: '{{ output }}'
|
Hello - Thank you for publishing this module. I have recently been tasked with having to automate large lists of VMs within a pipeline and I have ansible and ansible AWX. I followed the module guides and installed it from Galaxy as described in the readme. Initially, I was only interested in the VM portion of the module so I pulled the examples and used them to form a playbook to build the vm's. Upon execution of the playbook, it will run and create the VMs however if the same playbook is executed again it will build the VMs again and appears to have no idempotency.
I'd like to try again and leverage the module as described and documented here only modifying or supplying what is expected to accomplish a vm build. Can someone from the project give a more detailed description of the files that need to be modified to just get the basic VM deployment accomplished? I realize the module has far more to offer than just creating a VM, however, in most cases, this is where we often start and build upon that basic feature to more advanced deployments. I have yet to accomplish following the examples.
I have leveraged Ansible for a long time however in this use case I find I may need a bit more guidance to effectively leverage the module. Would one of the team be willing to have a working session or point me in a direction that may improve my success rate with utilizing the module?
Prism Central Version pc.2023.1.0.2
NCC 4.6.4
LCM 2.6.1
Glenn B
The text was updated successfully, but these errors were encountered: