Nutanix Move Automation: Using Ansible with Migration Plans - Nutanix Move Automation Using Ansible With Migrations Plans

A cloud-first strategy often results in IT and Operations staff working to “lift and shift” Virtual Machine (VM) workloads from on-premises infrastructure to private and public clouds. The lift and shift process can entail migrating VM storage and networking configuration onto a new infrastructure provider, different hypervisor version, or even an entirely different hypervisor. When dealing with multiple VMs, complexity increases and migration by hand becomes risky. The migration process should be assisted by automation to minimize downtime, allow repeatable and testable migrations, and insure reliable results.

This blog complements the video about using Ansible with Nutanix Move to start the cutover process on VMs that are waiting to start the cutover process. In this blog post, we will talk about what Nutanix Move is, the Ansible Role used in the video, and provide the role for download.

Nutanix Move

Nutanix Move is a free piece of software that customers can use to migrate virtual machines from AWS, Azure, HyperV, and ESXi to Nutanix AHV. You can also use Move to migrate to AWS from AHV and migrate from ESXi to ESXi running on Nutanix.

Move works with the different product APIs and does not need any agents to do the migrations.

You can see the process Move uses to migrate VMs in the above picture. Until you choose to do the cutover, the source VM will not be altered. Move will sync the data with the source VM every 10 minutes to limit the downtime. Customers have used this for on-premises migrations (3 tier ESXi to AHV), and the VM downtime is usually in the minutes, depending on the size of the dataset.

Nutanix Move is supplied as an appliance VM and is downloaded from the support portal. The VM can be set up on a target cluster with network access to the source cluster or clusters. Once the VM is set up, you will have the username, password and IP of the Move VM IP address to use in the ansible playbook.

Move Automation

Move can schedule the time to start the data migration when moving VMs from other platforms to Nutanix AHV. However, the cutover step is something that needs to be started manually. The Ansible playbook was created to let you schedule the cutover time.

The playbook is built off of the Nutanix VM Provisioner role that is on Ansible Galaxy. Using the structure the role creators started with, the role was modified to work with Move. New tasks were created for Move, which should allow this role to be expanded and allow Ansible to automate more of Move. 

The new Tasks (listed below) are referenced in the move.yml file located in the tasks folder of the role.

  • get_session_token.yml: a login task that will login to the Move appliance and save the login token to be used in the other tasks that are run when the role is called in the playbook.
  • list_plans.yml: this task gets a list of the plans and uses the names specified in the playbook vars section, and matches it to the UUID that matches the plan name and saves it as a fact.
  • workloads.yml: this task performs the cutover, using the information gathered in the previous tasks. This pulls the VM name that was specified in the playbook vars section and checks to make sure that the VM is in the right state for cutover. If the VM is not in the correct state, the playbook will fail and display the reason for the failure.

Now that we know what the new tasks are, how would you go about using this role? First, you would need to create an Ansible playbook file. You would create that playbook file in a directory, then copy the Move folder you have downloaded from GitHub and uncompressed into that same directory.

In the move folder is a file that provides an example playbook:

- name: Move Operations
  hosts: localhost
  gather_facts: false
    - name: Move Operations
        name: move
# vars can be also added in the defaults/main.yml file
        vm_name: your vm name
        plan_name: your migration plan name
# Supported Actions: cutover, test, retest, undotest, retry, discard, abort  
        action: cutover

You should modify the vm_name and plan_name variables. The default action can be changed, and you can use any of the actions you like, such as test if you wanted to create a test VM on a separate network to test the cutover.

Now that you have your Ansible playbook setup, you need to go into the Move directory and open the defaults folder. Open the main.yml in that directory with your favorite editor. I tend to like VScode. The Code should look like below.

# defaults file for move_opersations
# Control debug
global_debug: false
# Nutanix Move Settings
api_version: "2.0"
move_ip: your move ip
move_api_url: "https://{{ move_ip }}/move/v2"
move_username: "nutanix"
move_password: "yourmovepassword"
# plan_name: "My Plan"
# vm_name: "Your vm name"
# action: cutover

Supply your move_ip and the move_password you set when you installed Move. The default move_username should be nutanix, but you need to specify if it is different. If you want, you can put the plan_name, vm_name, and action parameters in the defaults.yml file instead of the playbook; it will work with them specified here.

Once you have the playbook.yml setup and the defaults/main.yml settings set, you can run the playbook. You would do that by running the following command:

ansible-playbook playbookname.yml

You can see how this looks in the video linked below.

You can download this Ansible role from from the nutanix-move directory within our ansible repository