Created
February 13, 2012 16:52
-
-
Save cwebberOps/1818165 to your computer and use it in GitHub Desktop.
openvz fun
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
container {"puppet": | |
state => "running", | |
id => 201, | |
interfaces => ['web0,00:0C:29:1E:3C:25,puppet_web0,00:0C:29:E3:AF:E1,br_web', 'pb0,00:0C:29:56:B0:F5,puppet_pb0,00:0C:29:DD:42:BC,br_public', 'infra0,00:0C:29:03:E9:C1,puppet_infra0,00:0C:29:C7:D0:5A,br_infra', 'clust0,00:0C:29:B3:B5:60,puppet_clust0,00:0C:29:5E:93:B1,br_clust'], | |
network => { | |
"pb0" => { | |
"address" => "138.23.xx.xx", | |
"netmask" => "255.255.255.128", | |
"gateway" => "138.23.51.1" | |
}, | |
"web0" => { | |
"address" => "192.168.1.2", | |
"netmask" => "255.255.255.0" | |
}, | |
"infra0" => { | |
"address" => "192.168.0.8", | |
"netmask" => "255.255.255.0" | |
}, | |
"clust0" => { | |
"address" => "192.168.2.2", | |
"netmask" => "255.255.255.0" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define container ( | |
$state, | |
$interfaces, | |
$id, | |
$network, | |
$ram = 512, | |
$os_template = 'debian-6.0-x86' | |
) { | |
virt {$title: | |
ensure => $state, | |
id => $id, | |
interfaces => $interfaces, | |
virt_type => 'openvz', | |
autoboot => true, | |
memory => $ram, | |
os_template => $os_template, | |
require => File['/etc/vz/vznet.conf'] | |
} | |
file {"/var/lib/vz/private/${id}/etc/network/interfaces": | |
ensure => present, | |
owner => "root", | |
group => "root", | |
mode => 0644, | |
content => template("openvz/interfaces.erb"), | |
require => Virt[$title] | |
} | |
exec {"/usr/sbin/vzctl exec ${id} /etc/init.d/networking restart": | |
refreshonly => true, | |
subscribe => File["/var/lib/vz/private/${id}/etc/network/interfaces"] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@vz01:/etc/puppet/temp# puppet apply --verbose --modulepath=/etc/puppet/temp/modules manifests/site.pp | |
info: Loading facts in /etc/puppet/temp/modules/virt/lib/facter/virt_libvirt.rb | |
info: Loading facts in /etc/puppet/temp/modules/augeas/lib/facter/augeasversion.rb | |
info: Loading facts in /etc/puppet/temp/modules/mysql/lib/facter/mysql.rb | |
info: Loading facts in /etc/puppet/temp/modules/virt/lib/facter/virt_libvirt.rb | |
info: Loading facts in /etc/puppet/temp/modules/augeas/lib/facter/augeasversion.rb | |
info: Loading facts in /etc/puppet/temp/modules/mysql/lib/facter/mysql.rb | |
Parameter interfaces failed: interfaces field must an Array. web0,00:0C:29:1E:3C:25,puppet_web0,00:0C:29:E3:AF:E1,br_web is not an array at /etc/puppet/temp/modules/openvz/manifests/container.pp:19 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newproperty(:interfaces, :array_matching => :all) do | |
desc "Connect the guest network to the host using the specified network as a bridge. The value can take one of 2 formats: | |
`disabled`: | |
The guest will have no network. | |
`[ \"ethX\", ... ] | \"ethX\" ` | |
The guest can receive one or an array with interface's name from host to connect to the guest interfaces. | |
'ifname[,mac,host_ifname,host_mac,[bridge]]' | |
For OpenVZ hypervisor, the network interface must be specified using the format above, where: | |
* 'ifname' is the ethernet device name in the guest; | |
* 'mac' is its MAC address; | |
* 'host_ifname' is the ethernet device name on the host; | |
* 'host_mac' is its MAC address. MAC addresses should be in the format like XX:XX:XX:XX:XX:XX. | |
Bridge is an optional parameter which can be used in custom network start scripts to automatically add the interface to a bridge. All parameters except ifname are optional and are automatically generated if not specified. | |
If the specified interfaces does not exist, it will be ignored and raises a warning." | |
validate do |value| | |
unless value.is_a?(Array) | |
self.devfail "interfaces field must an Array. #{value} is not an array" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set type-virt.rb to self.devfail "interfaces field must an Array. #{value} is not an array\n\n Array Matching: #{self.array_matching}"
Now getting:
Parameter interfaces failed: Validate method failed for class interfaces: undefined method `array_matching' for #Puppet::Type::Virt::Interfaces:0xb64886e8