Automating VMware migrations

18 views
Skip to first unread message

Mario Zamora

unread,
Jan 24, 2019, 6:01:10 PM1/24/19
to Ansible Project
Hello, 

I have a playbook that I'm working on to migrate VMs to a new ESX host. I finally got 1 maybe 2 parts working where I can power-off the machine and power-on again. Here's where the maybe comes into play. 
When I run the playbook I can see the VM power-off and immediately power-on again, but let's say if I were to cut out the power-on task and put it back in there it can't detect the VM. 
I thought something like this would happen because how can ansible re-connect to a powered down host? By the way this is my first time using a tool like ansible and most of this playbook wasn't running at all... lot's of errors and mistakes. Haha


---
- name: Virtual Machine Migration Playbook
hosts: vmserver
vars:
VMWARE_PASSWORD: credentials
VMWARE_USER: credentials
VMWARE_HOST: credentials
VMWARE_VCENTER: credentials
remote_user: root
gather_facts: true
tasks:
- name: Test connectivity
ping:
- name: Wait for the virtual machine to shutdown
vmware_guest_powerstate:
hostname: "{{ VMWARE_VCENTER }}"
user: "{{ VMWARE_USER }}"
password: "{{ VMWARE_PASSWORD }}"
name: "{{ VMWARE_HOST }}"
state: powered-off
state_change_timeout: 200
validate_certs: no
delegate_to: localhost
register: deploy
- name: Wait for the virtual machine to poweron
vmware_guest_powerstate:
hostname: "{{ VMWARE_VCENTER }}"
user: "{{ VMWARE_USER }}"
password: "{{ VMWARE_PASSWORD }}"
name: "{{ VMWARE_HOST }}"
state: powered-on
state_change_timeout: 200
validate_certs: no
delegate_to: localhost
register: deploy
Reply all
Reply to author
Forward
0 new messages