mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -07:00
* Add proxmox_nic module
Add proxmox_nic module to manage NIC's on Qemu(KVM) VM's in a Proxmox VE
cluster.
Update proxmox integration tests and add tests for proxmox_nic module.
This partially solves https://github.com/ansible-collections/community.general/issues/1964#issuecomment-790499397
and allows for adding/updating/deleting network interface cards after
creating/cloning a VM.
The proxmox_nic module will keep MAC-addresses the same when updating a
NIC. It only changes when explicitly setting a MAC-address.
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
* Add check_mode and implement review comments
- check_mode added
- some documentation updates
- when MTU is set, check if the model is virtio, else fail
- trunks can now be provided as list of ints instead of vlanid[;vlanid...]
* Make returns on update_nic and delete_nic more readable
Co-authored-by: Felix Fontein <felix@fontein.de>
* Increase readability on update_nic and delete_nic
* Implement check in get_vmid
- get_vmid will now fail when multiple vmid's are returned as proxmox
doesn't guarantee uniqueness
- remove an unused import
- fix a typo in an error message
* Add some error checking to get_vmid
- get_vmid will now return the error message when proxmoxer fails
- get_vmid will return the vmid directly instead of a list of one
- Some minor documentation updates
* Warn instead of fail when setting mtu on unsupported nic
- When setting the MTU on an unsupported NIC model (virtio is the only
supported model) this module will now print a warning instead of
failing.
- Some minor documentation updates.
* Take advantage of proxmox_auth_argument_spec
Make use of proxmox_auth_argument_spec from plugins/module_utils/proxmox.py
This provides some extra environment fallbacks.
* Add blank line to conform with pep8
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 23dda56913
)
Co-authored-by: Kogelvis <github@ar-ix.net>
This commit is contained in:
parent
f5594aefd5
commit
ad5482f63d
3 changed files with 437 additions and 1 deletions
|
@ -48,7 +48,7 @@
|
|||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
register: results
|
||||
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is not changed
|
||||
|
@ -226,6 +226,92 @@
|
|||
- results_action_current.vmid == {{ vmid }}
|
||||
- results_action_current.msg == "VM test-instance with vmid = {{ vmid }} is running"
|
||||
|
||||
- name: VM add/change/delete NIC
|
||||
tags: [ 'nic' ]
|
||||
block:
|
||||
- name: Add NIC to test VM
|
||||
proxmox_nic:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
vmid: "{{ vmid }}"
|
||||
state: present
|
||||
interface: net5
|
||||
bridge: vmbr0
|
||||
tag: 42
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is changed
|
||||
- results.vmid == {{ vmid }}
|
||||
- results.msg == "Nic net5 updated on VM with vmid {{ vmid }}"
|
||||
|
||||
- name: Update NIC no changes
|
||||
proxmox_nic:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
vmid: "{{ vmid }}"
|
||||
state: present
|
||||
interface: net5
|
||||
bridge: vmbr0
|
||||
tag: 42
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is not changed
|
||||
- results.vmid == {{ vmid }}
|
||||
- results.msg == "Nic net5 unchanged on VM with vmid {{ vmid }}"
|
||||
|
||||
- name: Update NIC with changes
|
||||
proxmox_nic:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
vmid: "{{ vmid }}"
|
||||
state: present
|
||||
interface: net5
|
||||
bridge: vmbr0
|
||||
tag: 24
|
||||
firewall: True
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is changed
|
||||
- results.vmid == {{ vmid }}
|
||||
- results.msg == "Nic net5 updated on VM with vmid {{ vmid }}"
|
||||
|
||||
- name: Delete NIC
|
||||
proxmox_nic:
|
||||
api_host: "{{ api_host }}"
|
||||
api_user: "{{ user }}@{{ domain }}"
|
||||
api_password: "{{ api_password | default(omit) }}"
|
||||
api_token_id: "{{ api_token_id | default(omit) }}"
|
||||
api_token_secret: "{{ api_token_secret | default(omit) }}"
|
||||
validate_certs: "{{ validate_certs }}"
|
||||
vmid: "{{ vmid }}"
|
||||
state: absent
|
||||
interface: net5
|
||||
register: results
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- results is changed
|
||||
- results.vmid == {{ vmid }}
|
||||
- results.msg == "Nic net5 deleted on VM with vmid {{ vmid }}"
|
||||
|
||||
- name: VM stop
|
||||
tags: [ 'stop' ]
|
||||
block:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue