proxmox/manifests/hypervisor/cluster.pp

52 lines
1.6 KiB
ObjectPascal
Raw Normal View History

# == Class: proxmox::hypervisor::cluster
#
# Manage the Proxmox cluster.
#
class proxmox::hypervisor::cluster
{
File {
owner => root,
group => root,
mode => 644,
}
Exec {
path => [ '/bin', '/sbin', '/usr/bin', '/usr/sbin' ],
logoutput => 'on_failure',
}
if $::is_proxmox == 'true' and $proxmox::hypervisor::cluster_master_ip != undef and $proxmox::hypervisor::cluster_name != undef {
# Ensure the root user got an ssh-key
exec { 'create ssh-key for root':
command => 'ssh-keygen -t rsa -f /root/.ssh/id_rsa -b 2048 -N "" -q',
creates => '/root/.ssh/id_rsa.pub',
}
# Test if this node should be the master or a node
2015-03-18 10:50:03 +01:00
## has_interface_with needs double quoted string for the argument !
if has_interface_with('ipaddress', "${proxmox::hypervisor::cluster_master_ip}") {
# Create the cluster on this node
exec { "Create ${proxmox::hypervisor::cluster_name} cluster on ${proxmox::hypervisor::cluster_master_ip}":
command => "pvecm create ${proxmox::hypervisor::cluster_name}",
onlyif => 'uname -r | grep -- "-pve"',
creates => '/etc/pve/cluster.conf',
}
}
else {
# Connect this node to the cluster
exec { "Connect to ${proxmox::hypervisor::cluster_name} cluster":
command => "pvecm add ${proxmox::hypervisor::cluster_master_ip}",
onlyif => 'uname -r | grep -- "-pve"',
creates => '/etc/pve/cluster.conf',
}
}
}
#notify { "Master IP: ${proxmox::hypervisor::cluster_master_ip} and Cluster name: ${proxmox::hypervisor::cluster_name}": }
} # Private class: proxmox::hypervisor::cluster