Install, configure Ansible Automation Plaform and launch a migration

Install AWX

In the bastion:

Create the awx namespace:

oc new-project awx

Create the kustomization file pointing to the AWX operator repository:

cat << EOF > /home/lab-user/kustomization.yaml
kind: Kustomization
resources:
  # Find the latest tag here: https://github.com/ansible/awx-operator/releases
  - github.com/ansible/awx-operator/config/default?ref=2.19.1

# Set the image tags to match the git version from above
images:
  - name: quay.io/ansible/awx-operator
    newTag: 2.19.1

# Specify a custom namespace in which to install AWX
namespace: awx
EOF

Apply the kustomization file:

kubectl apply -k .

Then, create the AWX deployment:

cat << EOF | oc apply -f -
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
  name: awx-vmware-migrations
spec:
  service_type: clusterip
  ingress_type: Route
EOF

After a few seconds, you should see the operator begin to create new resources:

kubectl get pods -l "app.kubernetes.io/managed-by=awx-operator"
Sample Output
Name                                               Phase
NAME                        READY   STATUS    RESTARTS   AGE
awx-vmware-migrations-77d96f88d5-pnhr8   4/4     Running   0          3m24s
awx-vmware-migrations-postgres-0         1/1     Running   0          3m34s
kubectl get svc -l "app.kubernetes.io/managed-by=awx-operator"
Sample Output
NAME                TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)        AGE
awx-vmware-migrations-postgres   ClusterIP   None           <none>        5432/TCP       4m4s
awx-vmware-migrations-service    NodePort    10.109.40.38   <none>        80:31006/TCP   3m56s

Make sure all the pods are running. (You might need to wait around 4 minutes):

kubectl get pods -n awx
Sample Output
NAME                                               READY   STATUS      RESTARTS   AGE
awx-operator-controller-manager-745b55d94b-ptnzh   2/2     Running     0          12m
awx-vmware-migrations-migration-24.6.1-fcjdm       0/1     Completed   0          3m27s
awx-vmware-migrations-postgres-15-0                1/1     Running     0          4m33s
awx-vmware-migrations-task-766d48c758-bhrrm        4/4     Running     0          3m55s
awx-vmware-migrations-web-6445b8f574-gfnng         3/3     Running     0          3m56s

Get the secret to access AWX dashboard:

kubectl get secret awx-vmware-migrations-admin-password -o jsonpath="{.data.password}" -n awx | base64 --decode ; echo

Get the route to access AWX dashboard:

oc get routes -n awx
Sample Output
NAME                    HOST/PORT                                                                 PATH   SERVICES                        PORT   TERMINATION     WILDCARD
awx-vmware-migrations   awx-vmware-migrations-awx.apps.cluster-{guid}.dynamic.redhatworkshops.io          awx-vmware-migrations-service   http   edge/Redirect   None

The URL of your AWX dashboard is:

awx-vmware-migrations-awx.apps.cluster-my-guid.dynamic.redhatworkshops.io

Navigate to that URL with your browser to continue the lab. (Use admin as username and the password obtained in the previous step)

Configuring AWX to Launch a Migration

Creating Credentials

  1. From the navigation panel, go to ResourcesCredentials.

  2. Click Add and set the following parameters:

    • Name: Bastion key

    • Credential Type: Machine

    • Username: cloud-user

    • SSH Private Key: File content from /home/lab-user/.ssh/my-guidkey.pem on the bastion

  3. Click Save

Creating an Inventory

  1. From the navigation panel, go to ResourcesInventories.

  2. Click Add Inventory and set the following parameters:

    • Name: Conversion Host Inventory

    • Organization: Default

  3. Click Save

Creating Hosts

Conversion Host

  1. From the navigation panel, go to ResourcesHosts.

  2. Click Add and set the following parameters:

    • Name: {rhoso_conversion_host_ip}

    • Inventory: Conversion Host Inventory

    • Variables:

ansible_ssh_user: cloud-user

Click Save

  1. From the navigation panel, go to ResourcesHosts.

  2. Click Add 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 Save

Migrator Host

  1. From the navigation panel, go to ResourcesHosts.

  2. Click Add and set the following parameters:

    • Name: migrator

    • Inventory: Conversion Host Inventory

    • Variables:

Click Save

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

Click Save

Creating an Execution Environment

  1. From the navigation panel, go to AdministrationExecution Environments.

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

    • Name: vmware migration kit execution environment

    • Image: quay.io/os-migrate/vmware-migration-kit:stable

  3. Click Save

Creating a Project

  1. From the navigation panel, go to ResourcesProjects.

  2. Click Create Project and set the following parameters:

  3. Click Save

Creating the Job Template

Preparing the ansibles variables needed for the conversion

Go back to the bastion, and 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 os_migrate_for_awx.yaml file that we will use when creating the project in the AWX dashboard:

cat << EOF > /home/lab-user/os-migrate-env/os_migrate_for_awx.yaml
os_migrate_tear_down: false
# 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

vms_list:
  - winweb01-my-guid

# 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

Configuring the Job Template

Go back to the AWX dashboard.

  1. From the navigation panel, go to ResourcesTemplates.

  2. Click Add Job Template and set the following parameters:

    • Name: Windows VM Migration

    • Inventory: Conversion Host Inventory

    • Project: vmware migration kit project

    • Playbook: playbooks/migration.yml

    • Execution Environment: vmware migration kit execution environment

    • Credentials: Bastion key

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

  3. Click Save

Running the Migration

  1. From the navigation panel, go to ResourcesTemplates.

  2. Locate the Windows VM Migration template.

  3. Click the rocket icon to launch the migration.

Access to the VM using Horizon

  1. Access to Horizon using the URL: https://horizon-openstack.apps.my-guid.dynamic.redhatworkshops.io

  2. In the top panel, Instances, click on the instance: winweb01-my-guid

  3. Click the tab Console to access to the console.