mbach04 / nutanix_vm_provisioner Goto Github PK
View Code? Open in Web Editor NEWAnsible role to provision Virtual machines on a Nutanix AHV
License: MIT License
Ansible role to provision Virtual machines on a Nutanix AHV
License: MIT License
We are getting an error at the Stash the image task. Can you advice what is the purpose of default([])? from our understanding it seems that you are trying to set the variable image_uuids to the result of query: default([]) + [ {'name': item.spec.name, 'uuid': item.metadata.uuid but please correct me if I am wrong. I am trying to see if I can write another query to get the value and define the variable
Error:
fatal: [nutanixserver]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ image_uuids | default([]) + [ {'name': item.spec.name, 'uuid': item.metadata.uuid } ] }}): can only concatenate str (not "list") to str"}
Hi, thanks for creating this role ! I am currently testing and had a question. In the playbook you have in the example you list localhost, when I try on mine I can see:
TASK [nutanix_provisioner : Auth to the cluster] ********************************************************************************************************************************************************************************************
fatal: [localhost]: UNREACHABLE! => {"changed": false, "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in "/tmp". Failed command was:
So I changed the localhost to an inventory list that has my NTNX cluster IP but failed to auth.
Thanks!
Hi Matt,
Getting an error when it gets to the task: Create fact with VM template. I'm also using python 3 as when I researched the error some people stated that python 3 removed dict.iteritems
ACTUAL RESULTS
TASK [nutanix_provisioner : Create fact with VM template contents] **************************************************************************************************************************************************************************
fatal: [10.71.30.80]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'iteritems'\n\nThe error appears to be in '/etc/ansible/roles/nutanix_provisioner/tasks/provision_vm.yml': line 11, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Create fact with VM template contents\n ^ here\n"}
I've tried examining the API for creating a VM from the explorer on my Nutanix cluster, however several of the fields in vm-body.yml.j2 and the official field names in the REST API explorer are different, for example "nic_list" in the j2 file and "vm_nics" on the REST API explorer. I've attempted to include the storage_container_uuid: "string" in the vm-body.yml.j2 file and received the following error. We're trying to place the disks within a container that has compression and EC enabled and would really rather not use the default container with edits made to it's config. Any help would be appreciated, below is the contents of my vm-body.yml/j2 file.
api_version: '3.0'
metadata:
kind: vm
spec:
cluster_reference:
kind: cluster
uuid: {{ cluster_uuid }}
name: {{ vm.vm_name }}
resources:
disk_list:
- data_source_reference:
kind: image
uuid: {{ image_uuid }}
{% for disk in vm.vm_disk_list %}
{% for k,v in disk.items() %}
- {{ k }}: {{ v }}
{% endfor %}
{% endfor %}
memory_size_mib: {{ vm.vm_ram }}
nic_list:
{% if vm.vm_ip is defined %}
- ip_endpoint_list:
- ip: {{ vm.vm_ip }}
{% endif %}
{% if subnet_uuid is defined and vm.vm_ip is defined %}
subnet_reference:
kind: subnet
uuid: {{ subnet_uuid }}
{% elif subnet_uuid is defined and vm.vm_ip is not defined %}
- subnet_reference:
kind: subnet
uuid: {{ subnet_uuid }}
{% endif %}
num_sockets: {{ vm.vm_num_sockets }}
num_vcpus_per_socket: {{ vm.vm_num_cpu_per_socket }}
storage_container_uuid: {{ storage_cont_uuid }}
power_state: 'ON'
guest_customization:
cloud_init:
user_data: {{ lookup('template','cloud-init.yml.j2') | b64encode }}
Hello!
We are trying to use Playbook without the guest customization at first, but are encountering error we cant seem to find a solution.
Removed the following lines from vm-body.yml.y2:
guest_customization:
cloud_init:
user_data: {{ lookup('template','cloud-init.yml.j2') | b64encode }}
Error is following:
TASK [nutanix : Debug | Print VM definitions] *********************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"vm_defs": [
{
"vm_disk_list": [
{
"disk_size_mib": 10000
}
],
"vm_ip": "10.0.0.0",
"vm_name": "test",
"vm_num_cpu_per_socket": 1,
"vm_num_sockets": 4,
"vm_ram": 2048
}
]
}
TASK [nutanix : Create fact with VM template contents] ************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ lookup('template', 'vm-body.yml.j2') | from_yaml }}): a string or stream input is required"}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.