-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate_proxmox_vm.yml
50 lines (43 loc) · 1.34 KB
/
update_proxmox_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
38
39
40
41
42
43
44
45
46
47
48
49
50
---
# Version 1.4.0
- hosts: "localhost"
vars:
proxmox_api_host: "pvehost1"
proxmox_api_user: "root@pam"
proxmox_api_password: "SuperSecretPassword"
proxmox_api_port: "8006"
boot_time: 180
vm_list:
- vm_name: myShinyVM1
- vm_name: myShinyVM2
snapshot: true
reboot_if_required: true
tasks:
- name: Logon to Proxmox Server
ansible.builtin.uri:
method: POST
validate_certs: false
return_content: true
url: "https://{{ proxmox_api_host }}:8006/api2/json/access/ticket"
body_format: json
body:
username: "{{ proxmox_api_user }}"
password: "{{ proxmox_api_password }}"
register: proxmox_session
become: false
- name: parse cookie data
ansible.builtin.set_fact:
proxmox_api_cookie:
Cookie: "PVEAuthCookie={{ proxmox_session.json.data.ticket }}"
CSRFPreventionToken: "{{ proxmox_session.json.data.CSRFPreventionToken }}"
no_log: true
- name: get information about all vms in the cluster
ansible.builtin.uri:
method: GET
validate_certs: false
url: "https://{{ proxmox_api_host }}:8006/api2/json/cluster/resources?type=vm"
headers: "{{ proxmox_api_cookie }}"
register: proxmox_cluster_information
- name: Patch VM
ansible.builtin.include_tasks: patch_vm.yml
loop: "{{ vm_list }}"