forked from shawarby/Inj-AE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rename_vm.yml
39 lines (34 loc) · 1.16 KB
/
rename_vm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
- name: get list of facts
vmware_guest_facts:
hostname: '{{ vc_name }}'
username: '{{ vc_user }}'
password: '{{ vc_pwd }}'
datacenter: "{{ dc_name }}"
name: "{{ vm_name }}"
folder: "{{ dc_folder }}"
validate_certs: False
register: vm_facts
- set_fact:
vm_uuid: "{{ vm_facts.instance.instance_uuid }}"
- name: Rename virtual machine from old name to new name using UUID
gather_facts: no
hosts: localhost
connection: local
tasks:
- name: Rename oldVM to newVM
vmware_guest:
hostname: "{{ lookup('env','VCENTER_HOSTNAME') }}"
username: "{{ lookup('env','VCENTER_USER') }}"
password: "{{ lookup('env','VCENTER_PASSWORD') }}"
validate_certs: False
cluster: "{{ cluster_name }}"
uuid: "{{ vm_uuid }}"
name: "{{ new_vm_name }}"
- name: Perform storage vMotion of of virtual machine to DS to rename disk
vmware_vmotion:
hostname: "{{ lookup('env','VCENTER_HOSTNAME') }}"
username: "{{ lookup('env','VCENTER_USER') }}"
password: "{{ lookup('env','VCENTER_PASSWORD') }}"
validate_certs: no
vm_name: '{{new_vm_name}}'
destination_datastore: '{{datastore}}'