* A new subclass to automates the creation of a cluster from the master and join from other nodes.
This commit is contained in:
parent
5946af1bda
commit
02ce788515
@ -4,7 +4,7 @@
|
||||
###
|
||||
|
||||
##### Features
|
||||
|
||||
* A new subclass to automates the creation of a cluster from the master and join from other nodes.
|
||||
|
||||
##### Changes
|
||||
* Update README.md.
|
||||
|
@ -63,16 +63,20 @@ class proxmox::hypervisor (
|
||||
$vz_service_manage = $proxmox::params::vz_service_manage,
|
||||
$vz_service_enabled = $proxmox::params::vz_service_enabled,
|
||||
$labs_firewall_rule = $proxmox::params::labs_firewall_rule,
|
||||
$cluster_master_ip = undef,
|
||||
$cluster_name = undef,
|
||||
) inherits proxmox::params {
|
||||
|
||||
include '::proxmox::hypervisor::preconfig'
|
||||
include '::proxmox::hypervisor::install'
|
||||
include '::proxmox::hypervisor::config'
|
||||
include '::proxmox::hypervisor::service'
|
||||
include '::proxmox::hypervisor::cluster'
|
||||
|
||||
Class['proxmox::hypervisor::preconfig'] ->
|
||||
Class['proxmox::hypervisor::install'] ->
|
||||
Class['proxmox::hypervisor::config'] ->
|
||||
Class['proxmox::hypervisor::service']
|
||||
Class['proxmox::hypervisor::service'] ->
|
||||
Class['proxmox::hypervisor::cluster']
|
||||
|
||||
} # Public class: proxmox::hypervisor
|
||||
|
52
manifests/hypervisor/cluster.pp
Normal file
52
manifests/hypervisor/cluster.pp
Normal file
@ -0,0 +1,52 @@
|
||||
# == 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
|
Loading…
Reference in New Issue
Block a user