ansible-collections / community.libvirt

Manage libvirt with Ansible
http://galaxy.ansible.com/community/libvirt
GNU General Public License v3.0
61 stars 42 forks source link

virt_net modify doesn't make changes permanently if a network is active #107

Closed Yannik closed 2 years ago

Yannik commented 2 years ago
SUMMARY

(copied from https://github.com/ansible/ansible/issues/64898)

Making a change using virt_net will act differently if the network is running, or inactive. If running, the change is made temporarily to the running network. If not running, the change is made to the config.

This is due to the libvirt.VIR_NETWORK_UPDATE_AFFECT_CURRENT flag being passed to the modify command at https://github.com/ansible/ansible/blob/b1360c0d943e50239c8f8bfb0c6ffb0feaad4e6d/lib/ansible/modules/cloud/misc/virt_net.py#L245

As per https://libvirt.org/html/libvirt-libvirt-network.html#virNetworkUpdateFlags this flag will "affect live if network is active, config if it's not active"

I believe this flag should in fact be set to libvirt.VIR_NETWORK_UPDATE_AFFECT_LIVE | libvirt.VIR_NETWORK_UPDATE_AFFECT_CONFIG by default, and possibly have an extra argument in the virt_net ansible module to change this behaviour.

ISSUE TYPE
COMPONENT NAME

virt_net

ANSIBLE VERSION
ansible [core 2.11.6] 
  config file = /home/yannik/ansible/ansible.cfg
  configured module search path = ['/home/yannik/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/yannik/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/yannik/ansible/vendor_collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.10 (main, Jan 17 2022, 00:00:00) [GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
community.libvirt             1.0.2  
CONFIGURATION
ANSIBLE_NOCOWS(/home/yannik/ansible/ansible.cfg) = True
csmart commented 2 years ago

Thanks @Yannik! I have added some comments on the merge request.