cybergavin.nutanix_vm_create

Ansible Role Name - cybergavin.nutanix_vm_create

================================================

This Ansible role allows you to create one or more virtual machines (VMs) on a Nutanix cluster.

Features

  • Create VMs using different disk images.
  • Provision VMs in various subnets.
  • Generate an inventory file that lists the IP addresses of the created VMs for use in other tasks.
  • Optionally, mount and enable Nutanix Guest Tools on the VMs after they are set up.

NOTE:

  • By default, the VMs are created with UEFI boot configuration. This can be changed in the vars/main.yml file.

Requirements

  • You need to provide a comma-separated values (CSV) file with the specifications for one or more VMs. Check the sample files/vm.csv in the role directory.
  • You also need to provide a variables file with the necessary values.

Role Variables

  • pc_cluster_fqdn: The FQDN or IP address for Prism Central.
  • cluster_name: The name of the Nutanix cluster where VMs will be created.
  • vm_data_csv: The path and name of the CSV file with the VM details.
  • global_debug: A flag for global debugging (true/false).
  • enable_ngt: Should Nutanix Guest Tools be enabled? (true/false).
  • boot_type: The boot type for all VMs - "UEFI" (default), "LEGACY," or "SECURE_BOOT".

Dependencies

There are no dependencies.

Tested Environment:

  • Ansible 2.9
  • Nutanix AOS 5.15.4
  • AHV 20190916.360

Example Usage After Installing the Ansible Role


STEP 1: Create a vars/main.yml file like this:

pc_cluster_fqdn: "prismcentral.contoso.com"   # FQDN/IP for Prism Central
cluster_name: "mynutanix"                     # Name of the Nutanix cluster
vm_data_csv: "files/vm.csv"                   # Path and name of the CSV file with VM details
global_debug: false                           # Global debug flag

STEP 2: Create a files/vm.csv file like this:

vm_name,ip,subnet_name,image_name,num_vcpu,memory_mib,disk_list_mib
testvm,10.1.1.10,webnet,rhel8-image,2,4096,10240-20480

STEP 3: Create a playbook named main.yml like this:

---
- name: Create VMs on Nutanix AHV
  hosts: localhost
  connection: local
  gather_facts: false
  vars_prompt:
    - name: prism_user
      prompt: Enter a username for Prism Central access
      private: no
    - name: prism_password
      prompt: Enter the password for the above user
      unsafe: yes
      private: yes
  tasks:
    - name: Include variables
      include_vars: dir=vars
    - name: Use Ansible role cybergavin.nutanix_vm_create
      include_role:
        name: cybergavin.nutanix_vm_create

NOTE: In this example, vars_prompt asks the user for Prism credentials. If you prefer to use a vault or another method to provide these credentials, ensure they go into the prism_user and prism_password variables.

STEP 4: Run the playbook:

ansible-playbook main.yml

NOTE:

  • An inventory file named files/inventory will be created, listing the IP addresses of the VMs created.
  • To enable Nutanix Guest Tools, set enable_ngt: true in vars/main.yml.

License

GPLv3.0

Author Information

Cybergavin - Cybergavin - GitHub

References

  • This role is inspired by the Ansible role mbach04.nutanix_vm_provisioner available at GitHub.
  • The mbach04.nutanix_vm_provisioner role is licensed under the MIT License, with Copyright (c) 2018 Red Hat.
Informazioni sul progetto

An Ansible role for creating Nutanix VMs on a single cluster

Installa
ansible-galaxy install cybergavin.nutanix_vm_create
Licenza
gpl-3.0
Download
137
Proprietario