gwerlas.libvirt
Libvirt
This guide helps you install, configure, and manage libvirt resources.
GitLab project: yoanncolin/ansible/roles/libvirt
Requirements
You need a Linux system set up with:
- SSH
- Python (for Ansible)
- Sudo
- A working package manager
- EPEL installed for EL7 distributions
You can use the gwerlas.system
role to assist you:
ansible-galaxy install gwerlas.system
Here's how to use it in your playbook:
- name: My playbook
hosts: all
roles:
- role: gwerlas.system
- role: gwerlas.libvirt
Facts
This role provides the following fact:
libvirt_packages
To get these facts without making changes to your nodes, use:
- name: My playbook
hosts: all
tasks:
- name: Get facts
ansible.builtin.import_role:
name: gwerlas.libvirt
tasks_from: facts
- name: Display
ansible.builtin.debug:
var: libvirt_packages
Tags
You can use specific tags to filter tasks:
provision
: Only provisions resources
Role Variables
A list of available variables and their default values can be found in defaults/main/*.yml
.
Dependencies
Ensure that community.libvirt
is installed on your system or specified in your requirements.yml
.
Example Playbook
Here is an example of how to install and configure libvirt on a node:
- name: Libvirt
hosts: all
roles:
- name: gwerlas.libvirt
To provision some resources, you can use:
- name: Libvirt
hosts: all
tasks:
- name: Just provision some resources
ansible.builtin.import_role:
name: gwerlas.libvirt
tasks_from: provision
vars:
libvirt_networks:
- name: my-bridge
forward:
mode: bridge
bridge:
name: br0
- name: my-nat
bridge:
name: br1
ip:
address: 192.168.0.1
netmask: 255.255.255.0
dhcp:
start: 192.168.0.2
end: 192.168.0.254
libvirt_pools:
- name: local-dir
path: /data/images
- name: from-nfs
type: netfs
path: /data/images
source:
host: hostname
dir: /server-export
libvirt_domains:
- name: my-node
autostart: false
cpu:
mode: host-passthrough
model:
fallback: allow
memory: 4G
networks:
- name: my-bridge
- name: my-nat
vcpu:
placement: static
quantity: 2
volumes:
- name: os
- name: data
size: 200G
device: vdb
pool: data-dir
License
This project is licensed under the BSD 3-Clause License.
Installa
ansible-galaxy install gwerlas.libvirt
Licenza
bsd-3-clause
Download
2.3k
Proprietario
DevOps Engineer