2023-09-02 20:42:21 +00:00
|
|
|
- name: Proxmox test-vm-2
|
|
|
|
hosts: localhost
|
|
|
|
module_defaults:
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
api_user: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') | regex_replace('!.*') }}"
|
|
|
|
api_host: "{{ lookup('ansible.builtin.env', 'PROXMOX_HOST' ) }}"
|
|
|
|
api_token_id: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_ID') | regex_replace('.*!') }}"
|
|
|
|
api_token_secret: "{{ lookup('ansible.builtin.env', 'PROXMOX_TOKEN_SECRET') }}"
|
|
|
|
name: test-vm-2
|
|
|
|
node: pve
|
|
|
|
tasks:
|
|
|
|
- name: Create test-vm-2
|
|
|
|
community.general.proxmox_kvm:
|
2023-09-02 23:26:25 +00:00
|
|
|
tags:
|
|
|
|
- managed
|
|
|
|
register: vm
|
|
|
|
- name: Print VM data
|
2023-09-02 23:00:22 +00:00
|
|
|
ansible.builtin.debug:
|
2023-09-02 23:26:25 +00:00
|
|
|
msg: "{{ vm }}"
|
|
|
|
- name: Modify test-vm-2
|
|
|
|
module_defaults:
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
vmid: "{{ vm.vmid }}"
|
|
|
|
tasks:
|
|
|
|
- name: Wait for test-vm-2 to exist
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
state: current
|
|
|
|
retries: 30
|
|
|
|
delay: 10
|
|
|
|
- name: Update test-vm-2
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
cpu: x86-64-v3
|
|
|
|
memory: 2048
|
|
|
|
cores: 5
|
|
|
|
update: true
|
|
|
|
- name: Start test-vm-2
|
|
|
|
community.general.proxmox_kvm:
|
|
|
|
state: restarted
|