* (#3) Add a new class and subclass: proxmox::vm::openvz to manage OpenVZ CT
This commit is contained in:
parent
561b1fd91d
commit
c07826d2b2
|
@ -6,6 +6,7 @@
|
|||
* (#2) Add an array and a file to load additionnal modules.
|
||||
* Correct module's dependencies.
|
||||
* (#9) Add a puppetlabs-firewall rule.
|
||||
* (#3) Add a new class and subclass: proxmox::vm::openvz to manage OpenVZ CT
|
||||
|
||||
---------------------------------------
|
||||
|
||||
|
|
|
@ -41,11 +41,25 @@ class proxmox::params {
|
|||
# Firewall
|
||||
$labs_firewall_rule = false
|
||||
|
||||
|
||||
## VM - OpenVZ
|
||||
# Network
|
||||
$vm_interfaces_path = '/etc/network/interfaces'
|
||||
$vm_interfaces_content = 'proxmox/vm/openzv_interfaces.erb'
|
||||
$vm_interfaces_tail_path = '/etc/network/interfaces.tail'
|
||||
$vm_interfaces_tail_content = 'proxmox/vm/openzv_interfaces.tail.erb'
|
||||
$network_service_name = 'networking'
|
||||
$network_service_manage = true
|
||||
$network_service_enabled = true
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail("Proxmox only works with Debian system; osfamily (${::osfamily}) or lsbdistid (${::lsbdistid}) is unsupported")
|
||||
fail("Proxmox Virtual Environment only works with Debian system; And the OpenVZ configuration has been tested only with Debian; So osfamily (${::osfamily}) or lsbdistid (${::lsbdistid}) is unsupported")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
# == Class: proxmox::vm
|
||||
#
|
||||
# Manage Virtual Machines/VM (only OpenVZ right now)
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
#
|
||||
#
|
||||
# === Variables
|
||||
#
|
||||
#
|
||||
# === Examples
|
||||
#
|
||||
# include proxmox::vm
|
||||
#
|
||||
# === Authors
|
||||
#
|
||||
# Gardouille <gardouille@gmail.com>
|
||||
#
|
||||
# Copyright
|
||||
#
|
||||
# WTFPL <http://wtfpl.org/>
|
||||
#
|
||||
class proxmox::vm (
|
||||
$vm_interfaces_path = $proxmox::params::vm_interfaces_path,
|
||||
$vm_interfaces_content = $proxmox::params::vm_interfaces_content,
|
||||
$vm_interfaces_tail_path = $proxmox::params::vm_interfaces_tail_path,
|
||||
$vm_interfaces_tail_content = $proxmox::params::vm_interfaces_tail_content,
|
||||
$network_service_name = $proxmox::params::network_service_name,
|
||||
$network_service_manage = $proxmox::params::network_service_manage,
|
||||
$network_service_enabled = $proxmox::params::network_service_enabled,
|
||||
) inherits proxmox::params {
|
||||
|
||||
case $::virtual {
|
||||
'openvz': {
|
||||
include proxmox::vm::openvz
|
||||
}
|
||||
default: {
|
||||
fail(" => ${::virtual} <= virtual machines type is not yet supported.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} # Public class: proxmox::vm
|
|
@ -0,0 +1,39 @@
|
|||
# == Class: proxmox::vm::openvz
|
||||
#
|
||||
# Manage OpenVZ virtual machines (CT aka Containers)
|
||||
#
|
||||
class proxmox::vm::openvz {
|
||||
|
||||
File {
|
||||
owner => root,
|
||||
group => root,
|
||||
mode => 644,
|
||||
}
|
||||
|
||||
# Test if a virtual interface is available
|
||||
if $::ipaddress_eth0 {
|
||||
|
||||
if $::ipaddress_venet0_0 { # Virtual network available too?
|
||||
|
||||
# Need to configure eth0 in an interfaces.tail file because
|
||||
# the main interfaces file is auto-generated by PVE (for venet config)
|
||||
file { "${proxmox::vm::path_interfaces_tail_vm}":
|
||||
ensure => present,
|
||||
content => template("${proxmox::vm::content_interfaces_tail_vm}"),
|
||||
}
|
||||
|
||||
}
|
||||
else { # Only virtual interface is available
|
||||
|
||||
# If eth0 is the only interface, push it's configuration in the standard interfaces file
|
||||
file { "${proxmox::vm::path_interfaces_vm}":
|
||||
ensure => present,
|
||||
content => template("${proxmox::vm::content_interfaces_vm}"),
|
||||
}
|
||||
|
||||
} # fi
|
||||
} # fi; don't need any additionnal network configuration
|
||||
|
||||
|
||||
|
||||
} # Private class: proxmox::vm::openvz
|
|
@ -0,0 +1,12 @@
|
|||
# file generated by puppet
|
||||
# Don't edit, please see https://forge.puppetlabs.com/gardouille/proxmox
|
||||
|
||||
# Auto generated lo interface
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
# The main network interface
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
# file generated by puppet
|
||||
# Don't edit, please see https://forge.puppetlabs.com/gardouille/proxmox
|
||||
|
||||
# The main network interface
|
||||
auto eth0
|
||||
iface eth0 inet dhcp
|
||||
# Need to delete routes creates for venet interfaces
|
||||
up ip route flush table main
|
||||
# Add the default gateway throught eth0
|
||||
# <%= scope.lookupvar('::ipaddress_eth0') %>
|
||||
up ip route add default dev eth0
|
||||
up ip route add <%= scope.lookupvar('::network_eth0') %>/<%= scope.lookupvar('::netmask_eth0') %> dev eth0 protocol kernel src <%= scope.lookupvar('::ipaddress_eth0') %>
|
||||
up ip route add <%= scope.lookupvar('::network_venet0') %>/<%= scope.lookupvar('::netmask_venet0') %> dev venet0
|
||||
down ip route del default dev eth0
|
||||
down ip route del <%= scope.lookupvar('::network_venet0') %>/<%= scope.lookupvar('::netmask_venet0') %> dev venet0
|
Loading…
Reference in New Issue