Launch a VM Migration with Ansible Automation Platform

Configuring AAP to Launch a Migration

Creating Credentials

  1. From the navigation panel, go to Automation Execution → Infrastructure → Credentials.

  2. Click Create Credentials and set the following parameters:

    • Name: Bastion key

    • Credential Type: Machine

    • Username: cloud-user

    • SSH Private Key: File content from /home/lab-user/.ssh/{guid}key.pem on the bastion

  3. Click Create Credential

Creating an Inventory

  1. From the navigation panel, go to Automation Execution → Infrastructure → Inventories.

  2. Click Create Inventory → Create Inventory and set the following parameters:

    • Name: Conversion Host Inventory

    • Organization: Default

  3. Click Create Inventory.

Creating Hosts

Conversion Host

  1. From the navigation panel, go to Automation Execution → Infrastructure → Hosts.

  2. Click Create Host and set the following parameters:

    • Name: conversion_host

    • Inventory: Conversion Host Inventory

    • Variables:

ansible_host: {rhoso_conversion_host_ip}
ansible_ssh_user: cloud-user

Click Create Host.

Migrator Host

  1. From the navigation panel, go to Automation Execution → Infrastructure → Hosts.

  2. Click Create Host and set the following parameters:

    • Name: migrator

    • Inventory: Conversion Host Inventory

    • Variables:

ansible_connection: local
ansible_python_interpreter: '{{ ansible_playbook_python }}'

Click Create Host.

Creating an Execution Environment

If using OCP container registry:

Get the default route hostname

REG_ROUTE=$(oc get route default-route -n openshift-image-registry -o jsonpath='{.spec.host}')
PROJECT=aap

Your execution environment URL is:

echo $REG_ROUTE/$PROJECT/rhospvmt-ee:latest
  1. From the navigation panel, go to Automation Execution → Infrastructure → Execution Environments.

  2. Click Create Execution Environment and set the following parameters:

    • Name: VMware Migration toolkit execution environment

    • Image: default-route-openshift-image-registry.apps.cluster-{guid}.dynamic.redhatworkshops.io/aap/rhospvmt-ee:latest

  3. Click Create Execution Environment.

Creating a Project

  1. From the navigation panel, go to Automation Execution → Projects.

  2. Click Create Project and set the following parameters:

  3. Click Create Project.

Creating the Job Template

Preparing the Bastion

In the bastion, create the folder to store the ansible variables:

cd
mkdir -p /home/lab-user/os-migrate-env

Run the following commands to configure OpenStack CLI access:

oc project openstack
alias openstack="oc exec -t openstackclient -- openstack"

Retrieve necessary OpenStack parameters:

SECURITY_GROUP_ID=$(openstack security group list | awk '/ basic / {print $2}')
PROJECT_ID=$(openstack project list | grep ' admin ' | awk '{print $2}')
AUTH_URL=$(openstack endpoint list --service identity --interface public -c URL -f value)

Create the /home/lab-user/os-migrate-env/os_migrate_for_aap.yaml file:

cat << EOF > /home/lab-user/os-migrate-env/os_migrate_for_aap.yaml
os_migrate_tear_down: false
import_workloads_vmware_insecure: true
import_workloads_openstack_insecure: true
openstack_insecure: true
# osm working directory:
runner_from_aee: true
os_migrate_vmw_data_dir: /tmp/os-migrate
copy_openstack_credentials_to_conv_host: false

# Re-use an already deployed conversion host:
already_deploy_conversion_host: true

# If no mapped network, set the OpenStack network:
openstack_private_network: private

# Security groups for the instance:
security_groups: ${SECURITY_GROUP_ID}
use_existing_flavor: false

# Network settings for OpenStack:
os_migrate_create_network_port: true
copy_metadata_to_conv_host: true
used_mapped_networks: false

os_migrate_configure_network: true
import_workloads_vmware_insecure: true
vms_list:
  - haproxy-{vcenter_full_user}

# VMware parameters:
vcenter_hostname: {vcenter_hostname}
vcenter_username: {vcenter_full_user}
vcenter_password: {vcenter_password}
vcenter_datacenter: {vcenter_datastore}
local_disk_path: /local/disks

os_cloud_environ: demo.redhat.com
dst_cloud:
  auth:
    auth_url: ${AUTH_URL}
    username: admin
    project_id: ${PROJECT_ID}
    project_name: admin
    user_domain_name: Default
    password: openstack
  region_name: regionOne
  interface: public
  insecure: true
  openstack_insecure: true
  identity_api_version: 3
EOF

Configuring the Job Template

  1. From the navigation panel, go to Automation Execution → Templates.

  2. Click Create Template → Create Job Template and set the following parameters:

    • Name: HAProxy VM Migration

    • Inventory: Conversion Host Inventory

    • Project: vmware migration toolkit project

    • Playbook: playbooks/migration.yml

    • Execution Environment: VMware Migration toolkit execution environment

    • Credentials: Bastion key

    • Extra Variables: Copy the content of /home/lab-user/os-migrate-env/os_migrate_for_aap.yaml from the bastion

  3. Click Create Job Template.

Running the Migration

  1. From the navigation panel, go to Automation Execution → Templates.

  2. Locate the HAProxy VM Migration template.

  3. Click the rocket icon to launch the migration.

Note: The migration would take around 20 minutes. In the meantime, you can continue with the next lab and come back later to check the migration status.

Ping to the migrated VM

From the bastion, attach a floating IP to the migrated virtual machine:

openstack floating ip create public
openstack server add floating ip haproxy-{vcenter_full_user} {FLOATING_IP}

From the bastion, ping to the migrated virtual machine:

ping {FLOATING_IP}

Delete the VM in the RHOSO environment before the next lab

openstack server delete haproxy-{vcenter_full_user}
openstack volume delete haproxy-{vcenter_full_user}-202
openstack port delete haproxy-{vcenter_full_user}-NIC-0-VLAN-private-202

Troubleshooting the Migration

If the migration fails, or you want to troubleshoot the migration, you can access the logs by logging into the conversion host using the following command:

ssh -i /home/lab-user/.ssh/{guid}key.pem cloud-user@{rhoso_conversion_host_ip}

Then, you can access the logs of the migration using the following command:

sudo -i
less /tmp/osm-nbdkit-haproxy_{guid}-*.log