virt_net - Manage libvirt network configuration
New in version 2.0.
Synopsis
- Manage libvirt networks.
Requirements (on host that executes module)
- python >= 2.6
- python-libvirt
- python-lxml
Options
parameter | required | default | choices | comments |
---|---|---|---|---|
autostart | no |
| Specify if a given storage pool should be started automatically on system boot. | |
command | no |
| in addition to state management, various non-idempotent commands are available. See examples. Modify was added in version 2.1 | |
name | yes | name of the network being managed. Note that network must be previously defined with xml. aliases: network | ||
state | no |
| specify which state you want a network to be in. If 'active', network will be started. If 'present', ensure that network is present but do not change its state; if it's missing, you need to specify xml argument. If 'inactive', network will be stopped. If 'undefined' or 'absent', network will be removed from libvirt configuration. | |
uri | no | qemu:///system | libvirt connection uri. | |
xml | no | XML document used with the define command. |
Examples
# Define a new network - virt_net: command: define name: br_nat xml: '{{ lookup("template", "network/bridge.xml.j2") }}' # Start a network - virt_net: command: create name: br_nat # List available networks - virt_net: command: list_nets # Get XML data of a specified network - virt_net: command: get_xml name: br_nat # Stop a network - virt_net: command: destroy name: br_nat # Undefine a network - virt_net: command: undefine name: br_nat # Gather facts about networks # Facts will be available as 'ansible_libvirt_networks' - virt_net: command: facts # Gather information about network managed by 'libvirt' remotely using uri - 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) - virt_net: state: active name: br_nat # Ensure that a network is inactive - virt_net: state: inactive name: br_nat # Ensure that a given network will be started at boot - virt_net: autostart: yes name: br_nat # Disable autostart for a given network - virt_net: autostart: no name: br_nat
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/virt_net_module.html