Install the os-migrate vmware migration kit collection and execute a VM migration from CLI

Install os-migrate vmware migration kit in the bastion

In the bastion, install the ansible-core package, pyVim and python-openstacksdk:

sudo dnf -y install ansible-core python3-pyvmomi.noarch python-openstacksdk

In the os-migrate vmware kit ansible collection:

ansible-galaxy collection install os_migrate.vmware_migration_kit

Configure os-migrate vmware migration kit

Configure the Ansible inventory

In the bastion, create the ansible inventory:

cat << EOF > inventory.yaml
migrator:
  hosts:
    localhost:
      ansible_connection: local
      ansible_python_interpreter: "{{ ansible_playbook_python }}"

conversion_host:
  hosts:
    192.168.123.95:
      ansible_ssh_user: cloud-user
      ansible_ssh_private_key_file: /root/.ssh/id_rsa
EOF

Configure the Ansible inventory

In the bastion, create an alias to use the openstack command in the Red Hat OpenStack Services on OpenShift (RHOSO) deployment:

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

Get the security group ID:

SECURITY_GROUP_ID=$(openstack security group list | awk '/ basic / {print $2}')

Create the os_migrate_vars.yamls file:

cat << EOF > os_migrate_vars.yaml
runner_from_aee: false
# osm working directory:
os_migrate_vmw_data_dir: /opt/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 then 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

# Use for settings rhel network device:
os_migrate_configure_network: true

vms_list:
  - haproxy-my-guid
EOF
In the vms_list we specify the list of VMs to be migrated in this example, we will migrate the virtual machine haproxy-my-guid

Get the project ID and authurl from the tenant we are executing the conversion:

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

And finally create the secrets files with :

cat << EOF > secrets.yaml
# VMware parameters:
vcenter_hostname: {vcenter_console}
vcenter_username: {vcenter_full_user}
vcenter_password: {vcenter_password}
vcenter_datacenter: RS01

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
  identity_api_version: 3
EOF

Execute the virtual machine migration

Navigate to the the vcenter console: {vcenter_console} using username: {vcenter_full_user} and password: {vcenter_password}.

Ha-proxy-vm

Power on the virtual machine haproxy-my-guid

In the bastion, launch the migration:

ansible-playbook os_migrate.vmware_migration_kit.migration -i inventory.yaml -e @secrets.yaml -e @os_migrate_vars.yaml

Check that the VM has been migrated:

alias openstack="oc exec -t openstackclient -- openstack"
openstack server list
  1. Sample Output

+--------------------------------------+---------------+--------+-----------------------------------------+--------------------------+--------------------------+
| ID                                   | Name          | Status | Networks                                | Image                    | Flavor                   |
+--------------------------------------+---------------+--------+-----------------------------------------+--------------------------+--------------------------+
| 77844fc9-1c83-4328-8995-3c9a008e8134 | haproxy-tztc2 | ACTIVE | private=192.168.100.237, 192.168.123.97 | N/A (booted from volume) | osm-vmware-haproxy-tztc2 |
| 7fa1709c-4b6e-4adf-8098-f57a0ee43abd | centos9-ch    | ACTIVE | private=192.168.100.196, 192.168.123.95 | centos9-image            | migrate                  |
+--------------------------------------+---------------+--------+-----------------------------------------+--------------------------+--------------------------+

Ping the migrated VM:

ping 192.168.123.97
PING 192.168.123.97 (192.168.123.97) 56(84) bytes of data.
64 bytes from 192.168.123.97: icmp_seq=1 ttl=63 time=1.41 ms
64 bytes from 192.168.123.97: icmp_seq=2 ttl=63 time=0.792 ms