mbach04.nutanix_vm_provisioner

Nutanix VM Provisioner

This is a simple Ansible role designed to create virtual machines on Nutanix AHV using API version 3.

Required Variables

Here are the variables you need to set:

api_version: "3.0"          # Use version 3 of the API instead of version 2
cluster_url: 172.16.1.100   # The IP address for accessing PRISM
prism_user: admin           # User account with permissions to create VMs on the cluster
prism_password: secret      # Password for your account (store it securely, use Ansible vault)

cluster_name: "Your Cluster"      # Name of the cluster where you want to create VMs
subnet_name: "VMNet"              # The subnet (VLAN) for the new VMs
image_name: "RHEL_Server_7.5"     # Name of the disk image or ISO file to use

# A list of VMs you want to create
# You can split this into multiple lists for different VM groups.
vm_defs:
  - {vm_name: my-vm-01, vm_ip: '172.16.1.111', vm_ram: 8192, vm_num_cpu_per_socket: 1, vm_num_sockets: 1, vm_disk_list: [disk_size_mib: 152588]}

Cloud-init

If you don't want to use guest customization (like cloud-init), simply remove the guest_customization section from the templates/vm-body.yml.j2 file. Alternatively, you can make it a variable and submit your changes.

If you want to use cloud-init to set a user password, you can do this (though it’s not the safest practice).

Run this command on a RHEL host to generate a SHA-512 hashed password for the cloud_init_root_pass, which will be used with the kvm RHEL image:

python -c 'import crypt,getpass; print crypt.crypt(getpass.getpass())'

Place the generated string into cloud_init_root_pass in group_vars/*/all.yaml.

Example Playbook

Here's a basic example of how to provision VMs:

---
- name: Create some VMs
  hosts: localhost
  gather_facts: false
  vars:
    my_vms:
      - {vm_name: server1, vm_ip: '172.29.171.100', vm_ram: 4096, vm_num_cpu_per_socket: 1, vm_num_sockets: 4, vm_disk_list: [disk_size_mib: 76294, disk_size_mib: 152588]}
      - {vm_name: server2, vm_ip: '172.29.171.101', vm_ram: 4096, vm_num_cpu_per_socket: 1, vm_num_sockets: 4, vm_disk_list: [disk_size_mib: 76294, disk_size_mib: 152588]}
  tasks:
    - name: Create VMs on Nutanix
      include_role:
        name: nutanix_provisioner
      vars:
        vm_defs: "{{ my_vms }}"

License

This work is licensed under the MIT License. Check the LICENSE file for further details.

Author Information

Created by Matthew Bach and Timothy Ling from Red Hat.

Informazioni sul progetto

NAPS Team

Installa
ansible-galaxy install mbach04.nutanix_vm_provisioner
Licenza
mit
Download
325
Proprietario
Rusty Python and Golang hobbyist, Automation dude, Rick and Morty Fan