Reviewing playbook and role
Let's jump right into examining the role we created, named instance-migrate
. The completed role and file, named main.yml
, located in the instance-migrate/tasks
directory, looks like this:
--- - name: Retrieve hypervisor list shell: openstack --os-cloud="{{ CLOUD_NAME }}" hypervisor list | awk 'NR > 3' | awk '$4 != "{{ desthype }}" { print $4 }' register: hypelist - name: Collect pre-migration instance details shell: openstack --os-cloud="{{ CLOUD_NAME }}" server list --name "{{ instance }}" --long | awk 'NR > 3' | awk '{ print $16 }' register: preinststat - name: Disable unselected hypervisors command: nova "{{ AUTH_S }}" service-disable "{{ item }}" nova-compute --reason '{{ migreason }}' with_items: "{{hypelist.stdout_lines}}" - name: Migrate instance command: openstack --os-cloud="{{ CLOUD_NAME }}" server...