Giter Club home page Giter Club logo

puppet-libvirt's Introduction

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,
}

puppet-libvirt's People

Contributors

edestecd avatar igalic avatar kakwa avatar msimonin avatar thias avatar unicorn-ljw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

puppet-libvirt's Issues

pass configuration hashes for libvirth and quemu

it would be /way/ more convenient to pass two (four?) hashes to configure libvirtd, quemu, and their defaults (sysconfig) files.

This could be in a backwards compatible, or incompatible way, depending on our choosing / effort ;)

Management of Storage Pools

A cheap first target is to (optionally) delete the default pool.

The next step would be to allow for adding a Logical Volume Group as storage pool.

The rationale is that we want to be able to see storage capacity in virt-manager.

New release?

Hi @thias, do you have an estimate date for the next release of the module in the forge?

RHEL9 support

With RHEL9 nearly out and CentOS Stream 9 matching the projected RHEL9 runtime, can RHEL9 support be added to this module?

virtqemud

Is there support for the new virtqemud modular daemon?

add option to manage set_process_name for qemu.conf

After merging the qemu changes, my config is now being overridden, and the only parameter I ever touch in (set_process_name).
Can we please add it to the list options?

And while we're at it, maybe we should think about a less painful way of adding new options.

Perhaps an options hash that's passed into the Erb would be better. That way we could have closed up, dedicated namespaces for each subsystem (qemu, Xen, whathaveyou).

Add support for creating libvirt networks

I pushed ALL of my changes into this a network that adds support for a defined type, rigorously tests everything with rspec-puppet and spec-system and documents it in the README with fancy syntax highlighting.

My template Rakefile¹ which adds easy support for tagging and publishing packages is also in here as it ties in all whole tests.

I have also changed the contract to mdns_adv (now bool), and added dependencies (puppetlabs/stdlib) - but I haven't bumped the version. — If you chose to incorporate my changes, I'd rather you be the judge of that.

Add support for Linux Mint

Currently there is a check in params.pp for Ubuntu which sets correct service name and socket owner.
Extending this to cover Mint has no side effects and won't need additional maintenance

No Storage Pools Created

Using hiera, trying to use "create_resources" to create storage pools. I literally get nothing. I am not skilled with puppet, but I think I should get an error at least. However, no errors, nothing at all. The pool output remains the same, only default. Nothing. How do I troubleshoot this?

Module breaks w/ RHEL9 based and latest commit

There is a minor change that appears to be missed when adding rhel 9 family support in 56eea15 . Specifically, the network manifest is looking for a service (https://github.com/thias/puppet-libvirt/blob/master/manifests/network.pp#L92) based on the variable name but the service name (https://github.com/thias/puppet-libvirt/blob/master/manifests/init.pp#L77) is fixed for dependency purposes. I believe the network.pp file should be updated to use the fixed service name of libvirtd.

Ubuntu 20 fails as it does not have a libvirt-bin package

Whereas Ubuntu 18 did have a libvirt-bin package, Ubuntu 20 does not. When running the following on Ubuntu 20:

class { '::libvirt':
  virtinst           => true,
  defaultnetwork     => true
}

We get errors like:

Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install libvirt-bin' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Package libvirt-bin is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libvirt-bin' has no installation candidate
Error: /Stage[main]/Libvirt/Package[libvirt]/ensure: change from 'purged' to 'present' failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install libvirt-bin' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
Package libvirt-bin is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libvirt-bin' has no installation candidate
Notice: /Stage[main]/Libvirt/File[/etc/libvirt/libvirtd.conf]: Dependency Package[libvirt] has failures: true
Warning: /Stage[main]/Libvirt/File[/etc/libvirt/libvirtd.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/File[/etc/libvirt/qemu.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/File[/etc/sasl2/libvirt.conf]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/Service[libvirtd]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/Libvirt::Network[default]/Exec[create-/etc/libvirt/qemu/networks/default.xml]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/Libvirt::Network[default]/Exec[virsh-net-define-default]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/Libvirt::Network[default]/Exec[virsh-net-autostart-default]: Skipping because of failed dependencies
Warning: /Stage[main]/Libvirt/Libvirt::Network[default]/Exec[virsh-net-start-default]: Skipping because of failed dependencies

Is there a fix or workaround that we can use for Ubuntu 20 please?

Thanks.

is this module deprecated?

hi!

reading #74 and #24, it became clear to me that this module has not seen a lot of activity in recent years. there was 9c5d127 last year, but that was after 6 years of inactivity. there are a lot of pending pull requests and the fork network looks like a gnarled forest where everyone is trying to figure out how to fix the same issues.

Yet if you search for libvirt on the forge, you are very likely to find it. it's especially prominent if you sort by number of downloads, with a whopping 1.2M downloads, far ahead of the next one (cirrax-libvirt, ~40k downloads).

So it's very likely many people are doing the same mistake as I am and picking this module instead of cirrax, even though the latter is actively maintained, well featured, and actually works out of the box on Debian bullseye (which is still a problem here).

In #74, the example42 people were wondering if they should deprecate their module in favor of this one, but then eventually deprecated example42-libvirt in favor of the cirrax one.

so, it seems this module is really deprecated. shouldn't it be marked as such and point people at cirrax-libvirt instead?

thanks!

rspec-system tests fail to run corectly

I attemted to run the current rspec-system tests by using bundler to install the dependancies in the Gemfile, but the tests fail with "undefined method `success?' for #Hash:...".
I did check the beaker tests in #33, which did run corectly with the ubuntu 14 node.

Is it posible to get the tests to pass with a more specific set of gem versions, or must the rspec-system tests be replaced?

What's next ?

Thinking about the future of the module. To your mind what is needed now ?

Matt

add a parameter to change security_driver for qemu.conf

The default security driver is SELinux. If SELinux is disabled on the host, then the security driver will automatically disable itself. If you wish to disable QEMU SELinux security driver while leaving SELinux enabled for the host in general, then set this to 'none' instead.
security_driver = "selinux"
qemu.conf.erb

dependency on /etc/sasl2/qemu-kvm.conf

On wheezy, I got something like :

Error: Could not set 'file' on ensure: No such file or directory - /etc/sasl2/qemu-kvm.conf.puppettmp_5831 at 129:/tmp/vagrant-puppet-1/modules-0/libvirt/manifests/init.pp

when running with this simple manifest :

class { 'libvirt':
  defaultnetwork  => true,
  virtinst        => false,
  listen_tcp      => true,
  listen_tls      => false,
  auth_tcp        => 'none',
  tcp_port        => 16510,
  unix_sock_group => 'libvirt'
}

libvirt_pool fails on centos 6.5

Using the libvirt_pool type on centos 6.5 fails with

Error: Could not autoload puppet/provider/exec/windows: can't convert Hash into Integer
Error: Could not autoload puppet/type/exec: Could not autoload puppet/provider/exec/windows: can't convert Hash into Integer

The problem is probably related to the outdated ruby 1.8.7 on CentOS 6.5. The issue gets triggered by the include REXML line in the provider class (https://github.com/thias/puppet-libvirt/blob/master/lib/puppet/provider/libvirt_pool/virsh.rb#L4). This line can be removed if in line 150 the Document.new is replaced with REXML::Document.new. This fixes the issue.

Will try to provide a proper PR next week, just wanted to record this while it's fresh.

add support for configuring auth_unix_* options

The default debian (Ubunut?) libvirt daemon seems to have trouble when auth_unix_ro isn't explicitly set.

We should add this option to the template (and the init)

(n.b.: I have a patch in the pipe-line, but I don't know how easy it will merge)

Unknown variable warnings in puppetserver.log

I am using this module in its simplest form:

	class{ '::libvirt': }  # thias-libvirt

My puppet master log shows these warnings:

[admin@puppetmaster ~]# grep libvirt /var/log/puppetlabs/puppetserver/puppetserver.log
2018-04-18 15:42:16,353 WARN  [...] [puppetserver] Puppet Unknown variable: '::libvirt::params::auth_unix_rw'. at /etc/puppetlabs/code/environments/production/modules/libvirt/manifests/init.pp:48:32
2018-04-18 15:42:16,356 WARN  [...] [puppetserver] Puppet Unknown variable: '::libvirt::params::unix_sock_dir'. at /etc/puppetlabs/code/environments/production/modules/libvirt/manifests/init.pp:49:32

env info:

[admin@puppetmaster ~]# puppet --version
4.10.0
[admin@puppetmaster ~]# cat /etc/*elease | head -n 1
CentOS Linux release 7.3.1611 (Core) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.