Puppet Class: libvirt

Inherited by:
libvirt::config
libvirt::install
libvirt::service
Defined in:
manifests/init.pp

Overview

Libvirt (http://libvirt.org/) Puppet module

Examples:

using a drbd hook

class { 'libvirt':
  qemu_hook => 'drbd',
  qemu_conf => {
    'vnc_listen' => '0.0.0.0'
  }
}

Parameters:

  • service_name (String) (defaults to: 'libvirtd')

    Service name for libvirt. The default value is Distribution specific. Only set this if your setup differs from the packages provided by your distribution.

  • service_ensure (String) (defaults to: 'running')

    Whether the service should be running. Defaults to 'running'

  • service_enable (Boolean) (defaults to: true)

    Whether the service should be enabled. Defaults to true

  • manage_service (Boolean) (defaults to: true)

    Whether the service should be managed by this module. Defaults to true

  • libvirt_package_names (Array) (defaults to: [])

    Array of the libvirt packages to install. Required, see hiera data directory for defaults

  • qemu_hook_packages (Hash) (defaults to: {})

    Hash of Arrays of hook specific packages to install Defaults to {}

  • qemu_conf (Hash) (defaults to: {})

    Hash of key/value pairs you want to put in qemu.conf file.

  • qemu_hook (String) (defaults to: '')

    QEMU hook to install. The only currently available hook is a script to setup DRBD resources. Valid values are 'drbd' or '' (=no hook). Defaults to ''.

  • qemu_hook_packages (defaults to: {})

    Hash of Arrays of hook specific packages to install see hiera data directory for defaults

  • create_networks (Hash) (defaults to: {})

    Hash of networks to create with libvirt::network Defaults to {}

  • create_domains (Hash) (defaults to: {})

    Hash of domains to create with libvirt::domain Defaults to {}

  • create_nwfilters (Hash) (defaults to: {})

    Hash of nwfilters to create with libvirt::nwfilter Defaults to {}

  • evacuation (String) (defaults to: 'migrate')

    Default evacuation policy to shutdown or migrate all domains on a host. Valid values are 'migrate', 'save' and 'shutdown'. This can be overriden on a per domain basis. The default value is 'migrate'.

    Only useful together with the drbd qemu_hook in setups of two redundant virtualization hosts synchronized over DRBD. They have no effect if qemu_hook is not set to drbd.

  • max_job_time (String) (defaults to: '120')

    Default maximum job time in seconds when migrating, saving or shuting down domains with the manage-domains script. This can be overriden on a per domain basis. The default is 120.

    Only useful together with the drbd qemu_hook in setups of two redundant virtualization hosts synchronized over DRBD. They have no effect if qemu_hook is not set to drbd.

  • suspend_multiplier (String) (defaults to: '5')

    Default suspend_multiplier for migrating domains with the manage-domains script. This can be overriden on a per domain basis. The default is 5.

    Only useful together with the drbd qemu_hook in setups of two redundant virtualization hosts synchronized over DRBD. They have no effect if qemu_hook is not set to drbd.

  • migration_url_format (String) (defaults to: 'ssh')

    url format for to use for migration. default is ssh possible values: ssh: gives an url: 'qemu+ssh://%s/system' tls: gives an url: 'qemu+tls://%s/system' alias: sepcify the url as an alias in /etc/libvirt.conf

  • uri_aliases (Array) (defaults to: [])

    define aliases for a client to connect defaults to []

  • uri_default (String) (defaults to: '')

    the default url to use. defaults to '' (which means the system default is used)

  • default_conf (Hash) (defaults to: {})

    Hash to add config to /etc/default/libvirtd (Debian) or /etc/sysconfig/libvirtd (RedHat) Defaults to {}

  • libvirtd_conf (Hash[Optional[String],Variant[String,Integer,Array]]) (defaults to: {})

    Hash to add config to /etc/libvirt/libvirtd.conf Defaults to {}

  • config_dir (String) (defaults to: '/etc/libvirt')

    the directory for configurations. Defaults to '/etc/libvirt'

  • manage_domains_config (String) (defaults to: '/etc/manage-domains.ini')

    configuration file for managing domains. Defaults to '/etc/manage-domains.ini'

  • drop_default_net (Boolean) (defaults to: false)

    Boolean, don't create default network and bridge (virbr0) Defaults to false

  • diff_dir (String) (defaults to: '')

    if this is set to a path, the directory is created and the xmls generated for the domains are kept and diffs are shown on changes by puppet. usefull for development (or on upgrade) defaults to '' (== disabled)



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'manifests/init.pp', line 118

class libvirt (
  Array                                                $libvirt_package_names = [],
  String                                               $service_name          = 'libvirtd',
  String                                               $service_ensure        = 'running',
  Boolean                                              $service_enable        = true,
  Boolean                                              $manage_service        = true,
  Hash                                                 $qemu_conf             = {},
  String                                               $qemu_hook             = '',
  Hash                                                 $qemu_hook_packages    = {},
  Hash                                                 $create_networks       = {},
  Hash                                                 $create_domains        = {},
  Hash                                                 $create_nwfilters      = {},
  String                                               $evacuation            = 'migrate',
  String                                               $max_job_time          = '120',
  String                                               $suspend_multiplier    = '5',
  String                                               $migration_url_format  = 'ssh',
  Array                                                $uri_aliases           = [],
  String                                               $uri_default           = '',
  Hash                                                 $default_conf          = {},
  Hash[Optional[String],Variant[String,Integer,Array]] $libvirtd_conf         = {},
  String                                               $config_dir            = '/etc/libvirt',
  String                                               $manage_domains_config = '/etc/manage-domains.ini',
  Boolean                                              $drop_default_net      = false,
  String                                               $diff_dir              = '',
) {

  Anchor['libvirt::begin']
  -> Class['Libvirt::Install']
  -> Class['Libvirt::Config']
  -> Class['Libvirt::Service']
  -> Anchor['libvirt::installed']
  -> Anchor['libvirt::end']

  anchor { 'libvirt::begin': }
  include ::libvirt::install
  include ::libvirt::config
  include ::libvirt::service
  anchor { 'libvirt::installed': }
  anchor { 'libvirt::end': }

  # include manage-domains script config outside of the anchor to
  # avoid dependency cycles when declaring libvirt before and
  # libvirt::domains
  if ($qemu_hook == 'drbd') {
    include ::libvirt::manage_domains_config
  }

  if $diff_dir != '' {
    file{ [ $diff_dir, "${diff_dir}/domains", "${diff_dir}/networks", "${diff_dir}/nwfilters" ]:
      ensure  => directory,
      purge   => true,
      recurse => true,
    }
  }

  create_resources('::libvirt::network', $create_networks)
  create_resources('::libvirt::domain', $create_domains)
  create_resources('::libvirt::nwfilter', $create_nwfilters)

  if ( $drop_default_net ) {
    libvirt::network { 'default':
      ensure => 'absent',
    }
  }
}