community.libvirt.virt_net – Manage libvirt network configuration¶
Note
This plugin is part of the community.libvirt collection (version 1.0.0).
To install it use: ansible-galaxy collection install community.libvirt
.
To use it in a playbook, specify: community.libvirt.virt_net
.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.6
python-libvirt
python-lxml
Parameters¶
Examples¶
# Define a new network
- community.libvirt.virt_net:
command: define
name: br_nat
xml: '{{ lookup("template", "network/bridge.xml.j2") }}'
# Start a network
- community.libvirt.virt_net:
command: create
name: br_nat
# List available networks
- community.libvirt.virt_net:
command: list_nets
# Get XML data of a specified network
- community.libvirt.virt_net:
command: get_xml
name: br_nat
# Stop a network
- community.libvirt.virt_net:
command: destroy
name: br_nat
# Undefine a network
- community.libvirt.virt_net:
command: undefine
name: br_nat
# Gather facts about networks
# Facts will be available as 'ansible_libvirt_networks'
- community.libvirt.virt_net:
command: facts
# Gather information about network managed by 'libvirt' remotely using uri
- community.libvirt.virt_net:
command: info
uri: '{{ item }}'
with_items: '{{ libvirt_uris }}'
register: networks
# Ensure that a network is active (needs to be defined and built first)
- community.libvirt.virt_net:
state: active
name: br_nat
# Ensure that a network is inactive
- community.libvirt.virt_net:
state: inactive
name: br_nat
# Ensure that a given network will be started at boot
- community.libvirt.virt_net:
autostart: yes
name: br_nat
# Disable autostart for a given network
- community.libvirt.virt_net:
autostart: no
name: br_nat
# Add a new host in the dhcp pool
- community.libvirt.virt_net:
name: br_nat
command: modify
xml: "<host mac='FC:C2:33:00:6c:3c' name='my_vm' ip='192.168.122.30'/>"
Authors¶
Maciej Delmanowski (@drybjed)