-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmware_ram_playbook.yml
68 lines (63 loc) · 2.16 KB
/
vmware_ram_playbook.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
# https://letsdocloud.com/?p=524
# ansible-playbook -i hosts vmware_snapshot_take_playbook.yml
- name: Get VMs
# hosts: localhost
hosts: machines
connection: local
tasks:
- name: include vars
include_vars:
dir: group_vars
- name: Gather VM
#vmware_guest_facts:
vmware_guest_info:
validate_certs: False
hostname: '{{ site }}{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: '{{ site }}{{ vcenter_datacenter }}'
# name: "usrdavs012ccp8a"
name: "{{ inventory_hostname }}"
schema: "vsphere"
properties: ["config.hardware.memoryMB", "guest.disk", "guest.net", "overallStatus"]
delegate_to: localhost
register: vminfo
- debug:
msg: "{{ vminfo }}"
- name: Wait for the virtual machine to shutdown
vmware_guest_powerstate:
hostname: '{{ site }}{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
folder: "{{ vcenter_folder }}"
name: "{{ inventory_hostname }}"
state: shutdown-guest
state_change_timeout: 200
validate_certs: False
delegate_to: localhost
register: vm_state
- name: Setting guest memory to "{{ ram_os_upgrade }}"
vmware_guest:
hostname: '{{ site }}{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: '{{ site }}{{ vcenter_datacenter }}'
folder: "{{ vcenter_folder }}"
name: "{{ inventory_hostname }}"
state: present
hardware:
memory_mb: "{{ ram_os_upgrade }}"
validate_certs: False
delegate_to: localhost
- name: Set the state of VMs back to poweron
vmware_guest_powerstate:
hostname: '{{ site }}{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
folder: "{{ vcenter_folder }}"
name: "{{ inventory_hostname }}"
state: powered-on
validate_certs: False
delegate_to: localhost
register: deploy