Skip to content

Commit

Permalink
feat: Allow to update VMs with new values
Browse files Browse the repository at this point in the history
Because the proxmox_kvm module is not idempotent when `update: true`,
add a new variable `proxmox_kvm_update` that allows to run the update on
demand.

Also replace `refresh` with `update` which is more accurate and matches
the name of the module parameter. Note that `item.update` is not usable
since `update` is a method of python dicts. Ensure that `update` is
defined before using it.

Closes: #30
Fixes: #29
  • Loading branch information
btravouillon committed Mar 27, 2023
1 parent d45171f commit 2a500cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions roles/vm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ By default, the proxmox modules in `community.general` do not validate SSL
certs. To enable certificate validation, define the variable:

- `proxmox_api_validate_certs: true`

To enable update of VMs with new values:

- `proxmox_kvm_update: true`
3 changes: 3 additions & 0 deletions roles/vm/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
# certs. Make this a default for use with other modules like
# `ansible.builtin.uri` (used for API calls)
proxmox_api_validate_certs: false

# Do not update the VM when proxmox_kvm runs
proxmox_kvm_update: false
7 changes: 6 additions & 1 deletion roles/vm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
scsi: "{{ item.scsi | default(omit) }}"
scsihw: "{{ item.scsihw | default(omit) }}"
tags: "{{ item.tags | default(omit) }}"
update: "{{ item.refresh | default(omit) }}"
update: "
{% if 'update' in item %}
{{ item['update'] }}
{% else %}
{{ proxmox_kvm_update }}
{% endif %}"
validate_certs: "{{ proxmox_api_validate_certs }}"
virtio: "{{ item.virtio | default(omit) }}"
vmid: "{{ item.vmid }}"
Expand Down

0 comments on commit 2a500cc

Please sign in to comment.