Version information
This version is compatible with:
- Puppet Enterprise 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >=2.7.20 <8.0.0
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'thias-libvirt', '1.0.2'
Learn more about managing modules with a PuppetfileDocumentation
puppet-libvirt
Overview
Libvirt module. Useful on minimal Red Hat Enterprise Linux and Debian/Ubuntu installations which need to be configured as KVM virtualization hosts.
libvirt
: Main class to install, enable and configure libvirt.libvirt::network
: Definition to manage libvirt networks.
Examples
Use all of the module's defaults :
include '::libvirt'
Typical KVM/qemu host for virtualization :
class { '::libvirt':
mdns_adv => false
}
Change even more defaults :
class { '::libvirt':
defaultnetwork => true,
virtinst => false,
unix_sock_group => 'wheel',
unix_sock_rw_perms => '0770',
}
The module also allows the user to customize qemu parameters :
class { '::libvirt':
qemu_vnc_listen => "0.0.0.0",
qemu_vnc_sasl => true,
qemu_vnc_tls => false,
}
Configure Kerberos authentication:
class { '::libvirt':
listen_tls => false,
listen_tcp => true,
auth_tcp => 'sasl',
sysconfig => {
'LIBVIRTD_ARGS' => '--listen',
},
sasl2_libvirt_mech_list => 'gssapi',
sasl2_libvirt_keytab => '/etc/libvirt/krb5.tab',
qemu_vnc_listen => "0.0.0.0",
qemu_vnc_sasl => true,
qemu_vnc_tls => false,
sasl2_qemu_mech_list => 'gssapi',
sasl2_qemu_keytab => '/etc/qemu/krb5.tab',
sasl2_qemu_auxprop_plugin => 'sasldb',
}
Replace the default network with a PXE boot one :
class { '::libvirt':
defaultnetwork => false, # This is the default
}
$dhcp = {
'start' => '192.168.122.2',
'end' => '192.168.122.254',
'bootp_file' => 'pxelinux.0',
}
$ip = {
'address' => '192.168.122.1',
'netmask' => '255.255.255.0',
'dhcp' => $dhcp,
}
libvirt::network { 'pxe':
forward_mode => 'nat',
forward_dev => 'virbr0',
ip => [ $ip ],
}
We also support IPv6: It has the same sematics as ip:
# $ip = same as above
$ipv6 = {
address => '2001:db8:ca2:2::1',
prefix => '64',
}
libvirt::network { 'dual-stack':
forward_mode => 'nat',
forward_dev => 'virbr0',
ip => [ $ip ],
ipv6 => [ $ipv6 ],
}
While this might look a little convoluted in puppet code, this gives you the ability to specify networks in hiera, and then use create_resources()
to generate them:
---
libvirt_networks:
pxe:
autostart: true
forward_mode: nat
forward_dev: virbr0
ip:
- address: 192.168.122.1
netmask: 255.255.255.0
dhcp:
start: 192.168.122.2
end: 192.168.122.254
bootp_file: pxelinux.0
direct:
autostart: true
forward_mode: bridge
forward_dev: br0
forward_interfaces:
- eth0
and then in your manifest:
$networks = hiera('libvirt_networks', [])
create_resources($networks, $your_defaults_for_a_network)
On Red Hat Enterprise Linux, you might want to also manage changes to the
/etc/sysconfig/libvirtd
file. In this case, you pass the key/value pairs
of the variables to set inside the sysconfig
hash :
class { '::libvirt':
listen_tls => false,
listen_tcp => true,
sysconfig => {
'LIBVIRTD_ARGS' => '--listen',
'LIBVIRTD_NOFILES_LIMIT' => '4096',
},
}
Native Types
Libvirt Storage Pools
Puppet Resource
Query all current pools: $ puppet resource libvirt_pool
Examples
- Create a new directory pool :
libvirt_pool { 'mypool' :
ensure => present,
type => 'dir',
active => false,
target => '/tmp/pool-dir',
}
The above will define, build but not activate the pool.
By default a pool is activated ( same as active => true
).
By default a pool is not autostarted (same as autostart => false
).
- Create a
logical
pool (lvm
) and set the autostart flag :
libvirt_pool { 'lvm-pool' :
ensure => present,
type => 'logical',
autostart => true,
sourcedev => [ '/dev/sdb1', '/dev/sdc1' ],
sourcename => 'vg',
target => '/dev/vg'
}
- Remove the default pool :
libvirt_pool { 'default' :
ensure => absent,
}
2021-06-30 - 1.0.1
- Add support for Linux Mint (#55, @ssaki).
- Add support for RHEL8 with templates as close to the original as possible.
2015-04-28 - 1.0.0
- Strip whitespace to fix pool detection (#30, @CyBeRoni).
- Convert spec system to beaker tests (#33, @igalic).
- Fix activate vs. active in the README (#35, @unicorn-ljw).
- Pool simplify (#39, @igalic).
- Fix version comparison for puppet future parser (#40, @edestecd).
- Force LC_ALL=en_US.utf8 for all execs (#41, @kakwa).
- Replace Modulefile with metadata.json.
2014-05-05 - 0.3.2
- Bugfix for debian defaults with Puppet 2.7 (#28, @darktim).
- Add qemu_user and qemu_group parameters (#28, @darktim).
- Add support for RHEL7.
- Add version to the puppetlabs/stdlib dependency.
2014-01-31 - 0.3.1
- Fixed typo in init.pp (#23, @gigawhat).
2014-01-28 - 0.3.0
- Add /etc/default/libvirt-bin generation for debian systems (#15, @msimonin).
- Add type to manage storage pools (#16, @msimonin).
- Fix tests (#17, @igalic).
- Add initial configuration of qemu.conf (#18, @luisfdez).
- Add qemu_set_process_name parameter (#21).
- Add networks and networks_defaults parameters, useful from hiera (#9).
2013-10-16 - 0.2.3
- Fix for default sysconfig setting on RedHat.
- Add listen_addr, tcp_auth and tls_auth parameters.
2013-10-16 - 0.2.2
- Add sysconfig/libvirtd file management on RedHat osfamily.
- Add tls and tcp related parameters.
2013-10-14 - 0.2.1
- Add new libvirt::network definition (Igor Galić).
- Move all current parameters to the params class.
2013-10-07 - 0.2.0
- Add puppet-rspec and rspec system tests (Igor Galić).
- Add Debian/Ubuntu support (Igor Galić).
2013-10-04 - 0.1.1
- Add syntax highlighting tags to the README.
2013-05-24 - 0.1.0
- Update README and use markdown.
- Change to 2-space indent.
2012-08-29 - 0.0.1
- Clean up existing module.
Dependencies
- puppetlabs/stdlib (>= 3.2.0)
Copyright (C) 2012-2015 Matthias Saou Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.