Skip to content

Commit

Permalink
Optimize libvirt default network activation
Browse files Browse the repository at this point in the history
Added a check to determine if the libvirt default network is already active before attempting to start it, avoiding unnecessary attempts to start a network that is running. This enhancement streamlines the VM provisioning process and ensures the task is idempotent.
  • Loading branch information
RaneyDazed committed Feb 14, 2024
1 parent f45be7f commit 3015b47
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions roles/cockpit/tasks/subtasks/vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
state: latest
update_cache: true

- name: VM | Check if default network in libvirt is active
ansible.builtin.command:
cmd: virsh net-info default
register: default_network_info
changed_when: false

- name: VM | Start default network in libvirt
ansible.builtin.command:
cmd: virsh net-start default
when: not (default_network_info.stdout | regex_search('(Active:\\s*yes)', ignorecase=True))

0 comments on commit 3015b47

Please sign in to comment.