User Tools

Site Tools


cloud-init:deploy_new_vm

[HOWTO] Deploy any VM with Cloud-init

Documentation
Name: [HOWTO] Deploy any VM with Cloud-init
Description: Step by step guide to Deploy any VM with Cloud-init
Modification date :16/10/2018
Owner:dodger@ciberterminal.net
Notify changes to:backOps tuxe's
Tags: cloud-init

Option 0 [THE OPTION]: Project Clone Wars

Very long to paste the script here…

Step 1

All the documentation in its page: [SCRIPT] Project CloneWars.sh

Option 1: acli

Step 1 : yaml script

Standard cloud-init script

export THEHOSTNAME=thehostname
export THEIPADDRESS=theipaddress
export THENETMASK=thenetmask
export THEGATEWAY=thegateway
 
cat  cloud-init.TMPL.yaml| sed "s,THEHOSTNAME,${THEHOSTNAME},g" |sed "s,THEIPADDRESS,${THEIPADDRESS},g" | sed "s,THENETMASK,${THENETMASK},g" | sed "s,THEGATEWAY,${THEGATEWAY},g" > cloud-init.${THEHOSTNAME}.yaml

Step 2: Create vm

Connect to the CVM of the nutanix cluster.
Run acli and clone the template:

acli uhura.vm.clone_with_customize ${THEHOSTNAME} clone_from_vm=TMPL-CentOS7.1804_v002 cloudinit_userdata_path=file:///home/nutanix/cloud-init.${THEHOSTNAME}.yaml container="Container01"
acli vm.nic_delete ${THEHOSTNAME} $(acli vm.nic_list ${THEHOSTNAME}| egrep -v "^Mac Address"|awk '{print $1}')
acli vm.nic_create ${THEHOSTNAME} network="${THENETWORK}"

Step 3: Start the VM

acli vm.on ${THEHOSTNAME}

Option 2: Prism

Step 1 : yaml script

Step 1.1: Modify cloud-init template

Step 1.2: Validate yaml

Step 2: Create vm

Step 2.1: Add vm in nutanix

Add:

  • Name
  • Cores
  • Memory

Step 2.2: Add disk from Image

Step 2.3: Add network interface


With cloud init you can specify the Ip address including in UNMANAGED NETWORKS!!!
Sample:

Step 2.4: Add YAML script

Step 3: Start the VM

And enjoy the process in the console.
If you use the “normal” yaml script, the vm will restart at the end of the process.
And just after start, salt-minion will register on salt-master, you must accept keys to interact with the new server.

cloud-init/deploy_new_vm.txt · Last modified: 2019/07/18 09:43 (external edit)