proxmox/manifests/hypervisor/cluster.pp

53 lines
1.7 KiB
Puppet

# == 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
if has_interface_with("ipaddress", "${proxmox::hypervisor::cluster_master_ip}") {
#notify { "${::fqdn} will be the cluster master of ${proxmox::hypervisor::cluster_name}": }
# 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 {
#notify { "${::fqdn} will be a cluster node of cluster ${proxmox::hypervisor::cluster_name}": }
# 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