diff --git a/files/repackiso.py b/files/repackiso.py new file mode 100755 index 0000000..f768fa8 --- /dev/null +++ b/files/repackiso.py @@ -0,0 +1,145 @@ +#!/usr/bin/python +import shutil, tempfile, os, optparse, logging +import sys + +usage = "usage: %prog [options]" +parser = optparse.OptionParser(usage=usage) +parser.add_option("-i", "--isofile", help="ISO image", dest="isoimg") +parser.add_option("-d", "--domainid", help="Domain id ", dest="domainid") +parser.add_option("-n", "--vsmname", help="VSM name", dest="vsmname") +parser.add_option("-m", "--mgmtip", help="Management Ip address", dest="mgmtip") +parser.add_option("-s", "--mgmtsubnet", help="Management Subnet", dest="mgmtsubnet") +parser.add_option("-g", "--gateway", help="Management gateway", dest="mgmtgateway") +parser.add_option("-p", "--password", help="Admin account password", dest="adminpasswd") +parser.add_option("-r", "--vsmrole", help="VSM Role, primary ,secondary or standalone", dest="vsmrole") +parser.add_option("-f", "--file", help="Repackaged file", dest="repackediso") +(options, args) = parser.parse_args() + +isoimg = options.isoimg +domainid = int(options.domainid) +vsmname = options.vsmname +mgmtip = options.mgmtip +mgmtsubnet = options.mgmtsubnet +mgmtgateway = options.mgmtgateway +adminpasswd = options.adminpasswd +vsmrole = options.vsmrole +repackediso = options.repackediso + + +class Command(object): + """Run a command and capture it's output string, error string and exit status""" + def __init__(self, command): + self.command = command + + def run(self, shell=True): + import subprocess as sp + process = sp.Popen(self.command, shell = shell, stdout = sp.PIPE, stderr = sp.PIPE) + self.pid = process.pid + self.output, self.error = process.communicate() + self.failed = process.returncode + return self + + @property + def returncode(self): + return self.failed + +def createOvfEnvXmlFile(domain, gateway, hostname, ip, subnet, password, vsm_mode): + #TODO: write a proper xml + ovf_f = tempfile.NamedTemporaryFile(delete=False) + + st = ' \n' + st += ' $ctrlbridge, +# ensure => present +# } +# +# tapint {"$mgmttap": +# bridge => $mgmtbridge, +# ensure => present +# } +# +# tapint {"$pkttap": +# bridge => $pktbridge, +# ensure => present +# } + + + $diskfile = "/var/spool/vsm/${n1k_vsm::role}_disk" + + exec { "Exec_create_disk": + command => "/usr/bin/qemu-img create -f raw $diskfile ${n1k_vsm::disksize}G", + unless => "/usr/bin/virsh list | grep -c ' ${n1k_vsm::vsmname} .* running'", + } + -> + exec {"Debug_Exec_create_disk_debug": + command => "${n1k_vsm::Debug_Print} \"[INFO]\nExec_create_disk /usr/bin/qemu-img create -f raw $diskfile ${n1k_vsm::disksize}G\" >> ${n1k_vsm::Debug_Log}", + } + + $targetxmlfile = "/var/spool/vsm/vsm_${n1k_vsm::role}_deploy.xml" + file { "File_Target_XML_File": + path => "$targetxmlfile", + owner => 'root', + group => 'root', + mode => '666', + content => template('n1k_vsm/vsm_vm.xml.erb'), + require => Exec["Exec_create_disk"], + } + -> + exec {"Debug_File_Target_XML_FILE": + command => "${n1k_vsm::Debug_Print} \"[INFO]\nFile_Target_XML_File\n path=$targetxmlfile \n owner=root \n group=root \n mode=666 \n\" >> ${n1k_vsm::Debug_Log}", + } + + exec { "Exec_Create_VSM": + command => "/usr/bin/virsh define $targetxmlfile", + unless => "/usr/bin/virsh list | grep -c ' ${n1k_vsm::vsmname} .* running'", + } + -> + exec {"Debug_Exec_Create_VSM": + command => "${n1k_vsm::Debug_Print} \"[INFO]\nExec_Launch_VSM \n command=/bin/echo /usr/bin/virsh define $targetxmlfile \n unless=/usr/bin/virsh list --all | grep -c ' ${n1k_vsm::vsmname} ' \" >> ${n1k_vsm::Debug_Log}", + } + + exec { "Exec_Launch_VSM": + command => "/usr/bin/virsh start ${n1k_vsm::vsmname}", + unless => "/usr/bin/virsh list --all | grep -c ' ${n1k_vsm::vsmname} .* running '", + } + -> + exec {"Debug_Exec_Launch_VSM": + command => "${n1k_vsm::Debug_Print} \"[INFO]\nExec_Launch_VSM \n command=/bin/echo /usr/bin/virsh start ${n1k_vsm::vsmname} \n unless=/usr/bin/virsh list --all | grep -c ' ${n1k_vsm::vsmname} .* running' \" >> ${n1k_vsm::Debug_Log}", + } + + Exec["Exec_create_disk"] -> File["File_Target_XML_File"] -> Exec["Exec_Create_VSM"] -> Exec["Exec_Launch_VSM"] +} + diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..b546f96 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,46 @@ +class n1k_vsm( + $configureovs = false, + $ovsbridge, + $physicalinterfaceforovs = 'enp1s0f0', + $nodeip, + $nodenetmask, + $nodegateway, + $vsmname, + $consolepts = 2, + $role = 'primary', + $domainid, + $adminpasswd, + $mgmtip, + $mgmtnetmask, + $mgmtgateway, + $ctrlinterface, + $mgmtinterface, + $pktinterface, + $memory = 4096000, + $vcpu = 2, + $disksize = 4, + $n1kv_source = "puppet:///modules/n1k_vsm/vsm.iso", + $n1kv_version = "latest", + ) +{ + + $imgfile = "/var/spool/vsm/${role}_repacked.iso" + $diskfile = "/var/spool/vsm/${role}_disk" + + $Debug_Print = "/usr/bin/printf" + $Debug_Log = "/tmp/n1kv_vsm_puppet.log" + + # + # Clean up debug log + # + file {"File_$Debug_Log": + path => $Debug_Log, + ensure => "absent", + } + + include n1k_vsm::pkgprep_ovscfg + include n1k_vsm::vsmprep + include n1k_vsm::deploy + + File["File_$Debug_Log"] -> Class['n1k_vsm::pkgprep_ovscfg'] -> Class['n1k_vsm::vsmprep'] -> Class['n1k_vsm::deploy'] +} diff --git a/manifests/pkgprep_ovscfg.pp b/manifests/pkgprep_ovscfg.pp new file mode 100644 index 0000000..9ee8cb9 --- /dev/null +++ b/manifests/pkgprep_ovscfg.pp @@ -0,0 +1,264 @@ +class n1k_vsm::pkgprep_ovscfg { + + # Definition of sync points + + $Sync_Point_KVM = "##SYNC_POINT_KVM" + $Sync_Point_Virsh_Network = "##SYNC_POINT_VIRSH_NETWORK" + + case "$::osfamily" { + "RedHat": { + # + # Order indepedent resources + # + service {"Service_network": + name => "network", + ensure => "running", + restart => "/sbin/service network restart || /bin/true", + } + -> + exec {"Debug_Service_network": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Service_network\n name=network\n ensure=running\n enable=true\n restart=/sbin/service network restart\n\" >> ${n1k_vsm::Debug_Log}", + } + # VSM dependent packages installation section + # + # Eng note + # cwchang: Ideally we should have either of this logic + # 1. Have an iteration thru the package list in the $pkgs.each ... + # Somehow this syntax needs to turn on future parser by document + # 2. package resource should be able to run a name list + # Neither one works. We go for rudimentary one-by-one here for now. + # Pitfalls observed: + # 1. We cannot reassign variables for some reason + # 2. We cannot leave spaces in name + # qemu-kvm-rhev + package {"Package_qemu-kvm": + name => "qemu-kvm", + ensure => "installed", + before => Notify["$Sync_Point_KVM"], + } + -> + exec {"Debug_Package_qemu-kvm": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_qemu-kvm \n name=qemu-kvm \n ensure=installed\n\" >> ${n1k_vsm::Debug_Log}", + } + + package {"Package_virt-viewer": + name => "virt-viewer", + ensure => "installed", + before => Notify["$Sync_Point_KVM"], + } + -> + exec {"Debug_Package_virt-viewer": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_virt-viewer \n name=virt-viewer \n ensure=installed \n\" >> ${n1k_vsm::Debug_Log}", + } + + package {"Package_virt-manager": + name => "virt-manager", + ensure => "installed", + before => Notify["$Sync_Point_KVM"], + } + -> + exec {"Debug_Package_virt-manager": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_virt-manager \n name=virt-manager \n ensure=installed\n\" >> ${n1k_vsm::Debug_Log}", + } + + package {"Package_libvirt": + name => "libvirt", + ensure => "installed", + before => Notify["$Sync_Point_KVM"], + } + -> + exec {"Debug_Package_libvirt": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_libvirt \n name=libvirt \n ensure=installed\n\" >> ${n1k_vsm::Debug_Log}", + } + + package {"Package_libvirt-python": + name => "libvirt-python", + ensure => "installed", + before => Notify["$Sync_Point_KVM"], + } + -> + exec {"Debug_Package_libvirt-python": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_libvirt-python \n name=libvirt-python \n ensure=installed\n\" >> ${n1k_vsm::Debug_Log}", + } + + #package {"Package_python-virtinst": + # name => "python-virtinst", + # ensure => "installed", + # before => Notify["$Sync_Point_KVM"], + #} + #-> + #exec {"Debug_Package_python-virtinst": + # command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_python-virtinst \n name=python-virtinst \n ensure=installed \n\" >> ${n1k_vsm::Debug_Log}", + #} + + #package {"Package_genisoimage": + # name => "genisoimage", + # ensure => "installed", + # before => Notify["$Sync_Point_KVM"], + #} + #-> + #exec {"Debug_Package_genisoimage": + # command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_genisoimage \n name=genisoimage \n ensure=installed \n\" >> ${n1k_vsm::Debug_Log}", + #} + + package {"Package_ebtables": + name => "ebtables", + #ensure => "purged", + ensure => "installed", + before => Notify["$Sync_Point_KVM"], + } + -> + exec {"Debug_Package_ebtables": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_ebtables \n name=ebtables \n ensure=purged \n\" >> ${n1k_vsm::Debug_Log}", + } + + notify{"$Sync_Point_KVM":} + + service {"Service_libvirtd": + name => "libvirtd", + ensure => "running", + } + -> + exec {"Debug_Service_libvirtd": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Service_libvirtd\n name=libvirtd \n ensure=running \n\" >> ${n1k_vsm::Debug_Log}", + } + + # + # Virsh network exec configuration section + # + exec {"Exec_removenet": + command => "/usr/bin/virsh net-destroy default || /bin/true", + unless => "/usr/bin/virsh net-info default | /bin/grep -c 'Active: .* no'", + before => Notify["$Sync_Point_Virsh_Network"], + } + -> + exec {"Debug_Exec_removenet": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_removenet \n command=/usr/bin/virsh net-destroy default || /bin/true \n unless=/usr/bin/virsh net-info default | /bin/grep -c 'Active: .* no'\n\" >> ${n1k_vsm::Debug_Log}", + } + + exec {"Exec_disableautostart": + command => "/usr/bin/virsh net-autostart --disable default || /bin/true", + unless => "/usr/bin/virsh net-info default | /bin/grep -c 'Autostart: .* no'", + before => Notify["$Sync_Point_Virsh_Network"], + } + -> + exec {"Debug_Exec_disableautostart": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_disableautostart' \n command=/usr/bin/virsh net-autostart --disable default || /bin/true \n unless /usr/bin/virsh net-info default | grep -c 'Autostart: .* no'\" >> ${n1k_vsm::Debug_Log}", + } + + notify{"$Sync_Point_Virsh_Network":} + + package {"Package_openvswitch": + name => "openvswitch", + ensure => "installed", + } + -> + exec {"Debug_Package_openvswitch": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Package_openvswitch \n name=openvswitch \n ensure=installed\n\" >> ${n1k_vsm::Debug_Log}", + } + # + # bring up OVS and perform interface configuration + # + + service {"Service_openvswitch": + name => "openvswitch", + ensure => "running", + enable => "true", + } + -> + exec {"Debug_Service_openvswitch": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Service_openvswitch \n name=openvswitch \n ensure=running \n enable=true\n\" >> ${n1k_vsm::Debug_Log}", + } + + + exec {"Exec_AddOvsBr": + command => "/usr/bin/ovs-vsctl -- --may-exist add-br $n1k_vsm::ovsbridge", + } + -> + exec {"Debug_Exec_AddOvsBr": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_AddOvsBr \n command=/usr/bin/ovs-vsctl -- --may-exist add-br $n1k_vsm::ovsbridge \n \" >> ${n1k_vsm::Debug_Log}", + } + + # + # Modify Ovs bridge inteface configuation file + # + augeas {"Augeas_modify_ifcfg-ovsbridge": + name => "$n1k_vsm::ovsbridge", + context => "/files/etc/sysconfig/network-scripts/ifcfg-$n1k_vsm::ovsbridge", + changes => [ + "set DEVICE $n1k_vsm::ovsbridge", + "set BOOTPROTO none", + "set IPADDR $n1k_vsm::nodeip", + "set NETMASK $n1k_vsm::nodenetmask", + "set ONBOOT yes", + "set TYPE OVSBridge", + "set DEVICETYPE ovs", + ], + notify => Service["Service_network"], + } + -> + exec {"Debug_Augeas_modify_ifcfg-ovsbridge": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Augeas_modify_ifcfg-$n1k_vsm::ovsbridge \n name=$n1k_vsm::ovsbridge \n context=/files/etc/sysconfig/network-scripts/ifcfg-$n1k_vsm::ovsbridge \n\" >> ${n1k_vsm::Debug_Log}", + } + + # + # Modify Physical Interface config file + # + augeas {"Augeas_modify_ifcfg-physicalinterfaceforovs": + name => "$n1k_vsm::physicalinterfaceforovs", + context => "/files/etc/sysconfig/network-scripts/ifcfg-$n1k_vsm::physicalinterfaceforovs", + changes => [ + "set ONBOOT yes", + "set BOOTPROTO none", + "set TYPE OVSPort", + "set DEVICETYPE ovs", + "set OVS_BRIDGE $n1k_vsm::ovsbridge", + "rm IPADDR", + "rm NETMASK", + ], + } + -> + exec {"Debug_Augeas_modify_ifcfg-physicalinterfaceforovs": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Augeas_modify_ifcfg-physicalinterfaceforovs \n name=$n1k_vsm::physicalinterfaceforovs \n context=/files/etc/sysconfig/network-scripts/ifcfg-$n1k_vsm::physicalinterfaceforovs\n\" >> ${n1k_vsm::Debug_Log}", + } + + $intf=$n1k_vsm::physicalinterfaceforovs + $phy_bridge="/tmp/phy_bridge" + # + # Move physical port around from host bridge if any, to ovs bridge + # + #exec {"Exec_phy_bridge": + # command => "/usr/sbin/brctl show | /bin/grep $intf | /bin/sed 's/[\t ].*//' > $phy_bridge", + #} + #-> + #exec {"Debug_Exec_phy_bridge": + # command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_phy_bridge \n /usr/sbin/brctl show | /bin/grep $intf | /bin/sed 's/[\t ].*//' > $phy_bridge \n \" >> ${n1k_vsm::Debug_Log}", + #} + + exec {"Exec_rebridge": + #command => "/usr/bin/test -s $phy_bridge && /usr/sbin/brctl delif \$(cat $phy_bridge) $intf || /bin/true; /usr/bin/ovs-vsctl -- --may-exist add-port $n1k_vsm::ovsbridge $intf", + command => "/usr/bin/ovs-vsctl -- --may-exist add-port $n1k_vsm::ovsbridge $intf", + #notify => Service["Service_network"], + } + -> + exec {"Debug_Exec_rebridge": + #command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_rebridge \n /usr/bin/test -s $phy_bridge && /usr/sbin/brctl delif \$(cat $phy_bridge) $intf || /bin/true; /usr/bin/ovs-vsctl -- --may-exist add-port $n1k_vsm::ovsbridge $intf; /bin/rm -f $phy_bridge \n\" >> ${n1k_vsm::Debug_Log}", + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_rebridge \n /usr/bin/ovs-vsctl -- --may-exist add-port $n1k_vsm::ovsbridge $intf \n\" >> ${n1k_vsm::Debug_Log}", + } + + # + # Order enforcement logic + # + #Notify["$Sync_Point_KVM"] -> Service["Service_libvirtd"] -> Notify["$Sync_Point_Virsh_Network"] -> Package["Package_openvswitch"] -> Service["Service_openvswitch"] -> Exec["Exec_AddOvsBr"]->Augeas["Augeas_modify_ifcfg-ovsbridge"]->Augeas["Augeas_modify_ifcfg-physicalinterfaceforovs"]->Exec["Exec_phy_bridge"]->Exec["Exec_rebridge"] + Notify["$Sync_Point_KVM"] -> Service["Service_libvirtd"] -> Notify["$Sync_Point_Virsh_Network"] -> Package["Package_openvswitch"] -> Service["Service_openvswitch"] -> Exec["Exec_AddOvsBr"]->Augeas["Augeas_modify_ifcfg-ovsbridge"]->Augeas["Augeas_modify_ifcfg-physicalinterfaceforovs"]->Exec["Exec_rebridge"] + } + "Ubuntu": { + } + default: { + # + # bail out for unsupported OS + # + fail(": os[$os] is not supported") + } + } +} diff --git a/manifests/vsmprep.pp b/manifests/vsmprep.pp new file mode 100644 index 0000000..4c9ae86 --- /dev/null +++ b/manifests/vsmprep.pp @@ -0,0 +1,162 @@ +class n1k_vsm::vsmprep { + include 'stdlib' + + # + # VSM package source parsing logic + # + $source = $n1k_vsm::n1kv_source + + $source_method = regsubst($source, "^(.+):.*", '\1') + $dest = inline_template('<%= File.basename(source) %>') + + + $VSM_Bin_Prepare_Sync_Point="##VSM_BIN_PREPARE_SYNC_POINT" + $VSM_Spool_Dir="/var/spool/vsm" + $VSM_RPM_Install_Dir="/opt/cisco/vsm" + $VSM_Repackage_Script_Name="repackiso.py" + $VSM_Repackage_Script="/tmp/$VSM_Repackage_Script_Name" + $VSM_DEST="$VSM_Spool_Dir/$dest" + $VSM_PKG_NAME="nexus-1000v-vsm" + $VSM_ISO="vsm.iso" + + # + # prepare vsm spool folder + # + file {"File_VSM_Spool_Dir": + path => "$VSM_Spool_Dir", + ensure => "directory", + owner => "root", + group => "root", + mode => "664", + } + -> + exec {"Debug_File_VSM_Spool_Dir": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n File_VSM_Spool_Dir\n path=$VSM_Spool_Dir \n ensure=directory \n owner=root \n group=root \n mode=664 \n\" >> ${n1k_vsm::Debug_Log}", + } + + + case "$source_method" { + "http": { + yumrepo {"http-cisco-foreman": + baseurl => "$n1k_vsm::n1kv_source", + descr => "Internal repo for Foreman", + enabled => "1", + gpgcheck => "1", + proxy => "_none_", + gpgkey => "${n1k_vsm::n1kv_source}/RPM-GPG-KEY", + } + -> + package {"Package_VSM": + name => "$VSM_PKG_NAME", + ensure => "${n1k_vsm::n1kv_version}", + } + -> + exec {"Copy_VSM": + command => "/bin/cp $VSM_RPM_Install_Dir/*.iso $VSM_Spool_Dir/$VSM_ISO", + before => Notify["$VSM_Bin_Prepare_Sync_Point"], + } + -> + exec {"Debug-http-cisco-os and Package_VSM": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Debug-http-cisco-os and Package_VSM \n baseurl=$n1k_vsm::n1kv_source \n descr=>Internal repo for Foreman \n enabled = 1 \n gpgcheck=1 \n gpgkey => $n1kv_source::n1kv_source/RPM-GPG-KEY\n\" >> ${n1k_vsm::Debug_Log}", + } + } + + "ftp": { + package {"ftp": + name => "ftp", + ensure => "installed", + } + -> + yumrepo {"ftp-cisco-foreman": + baseurl => "$n1k_vsm::n1kv_source", + descr => "Internal repo for Foreman", + enabled => "1", + gpgcheck => "1", + proxy => "_none_", + gpgkey => "${n1k_vsm::n1kv_source}/RPM-GPG-KEY", + } + -> + package {"Package_VSM": + name => "$VSM_PKG_NAME", + ensure => "${n1k_vsm::n1kv_version}", + } + -> + exec {"Copy_VSM": + command => "/bin/cp $VSM_RPM_Install_Dir/*.iso $VSM_Spool_Dir/$VSM_ISO", + before => Notify["$VSM_Bin_Prepare_Sync_Point"], + } + -> + exec {"Debug-ftp-cisco-os and Package_VSM": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Debug-ftp-cisco-os and Package_VSM \n baseurl=$n1k_vsm::n1kv_source \n descr=>Internal repo for Foreman \n enabled = 1 \n gpgcheck=1 \n gpgkey => $n1kv_source::n1kv_source/RPM-GPG-KEY\n\" >> ${n1k_vsm::Debug_Log}", + } + + } + "puppet": { + # + # make sure the file does not exist + # + exec {"File_VSM_Bin_Remove": + command => "/bin/rm -f $VSM_DEST || /bin/true", + before => Notify["$VSM_Bin_Prepare_Sync_Point"], + } + -> + file {"File_VSM_Bin_Prepare": + path => "$VSM_DEST", + ensure => "present", + owner => "root", + group => "root", + mode => "664", + source => "$n1k_vsm::n1kv_source", + before => Notify["$VSM_Bin_Prepare_Sync_Point"], + } + -> + exec {"Exec_RPM_TO_ISO": + # + # If it's an RPM, we do a local rpm installation ..." + # + command => "/bin/rpm -i --force $VSM_DEST && /bin/cp $VSM_RPM_Install_Dir/*.iso $VSM_Spool_Dir/$VSM_ISO", + unless => "/usr/bin/file $VSM_DEST | /bin/grep -c ' ISO '", + before => Notify["$VSM_Bin_Prepare_Sync_Point"], + } + -> + exec {"Debug_File_VSM_Bin_Prepare_Exec_RPM_TO_ISO": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Debug_File_VSM_Bin_Prepare_Exec_RPM_TO_ISO \n path=$VSM_DEST \n ensure=directory \n owner=root\n group=root\n mode=664\n source=$n1k_vsm::n1kv_source\n \" >> ${n1k_vsm::Debug_Log}", + } + } + default: { + fail(": Unknown sourcing method [$source_method] is not supported") + } + } + + notify {"$VSM_Bin_Prepare_Sync_Point":} + + # + # copy repackiso.py to local place + # + file {"File_VSM_Repackage_Script_Name": + path => "$VSM_Repackage_Script", + ensure => "present", + owner => "root", + group => "root", + mode => "774", + source => "puppet:///modules/n1k_vsm/$VSM_Repackage_Script_Name", + } + -> + exec {"Debug_File_VSM_Repackage_Script_Name": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Debug_VSM_Repackage_Script_Name \n path=$VSM_Repackage_Script \n ensure=present \n owner=root \n group=root \n mode=774\n source=puppet:///modules/n1k_vsm/$VSM_REPACKAGE_SCRIPT_NAME \n\" >> ${n1k_vsm::Debug_Log}", + } + + # + # Now generate ovf xml file and repackage the iso + # + exec {"Exec_VSM_Repackage_Script_Name": + command => "${VSM_Repackage_Script} -i$VSM_Spool_Dir/$VSM_ISO -d${n1k_vsm::domainid} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::adminpasswd} -r${n1k_vsm::role} -f${VSM_Spool_Dir}/${n1k_vsm::role}_repacked.iso >> ${n1k_vsm::Debug_Log}", + } + -> + exec {"Debug_Exec_VSM_Repackage_Script_Name": + command => "${n1k_vsm::Debug_Print} \"[INFO]\n Exec_VSM_Repackage_Script_Name\n command=$VSM_Repackage_Script -i$VSM_ISO -d${n1k_vsm::domainid} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::adminpasswd} -r${n1k_vsm::role} -f${VSM_Spool_Dir}/${n1k_vsm::role}_repacked.iso \n\" >> ${n1k_vsm::Debug_Log}" + } + + File["File_VSM_Spool_Dir"]-> Notify["$VSM_Bin_Prepare_Sync_Point"]->File["File_VSM_Repackage_Script_Name"]->Exec["Exec_VSM_Repackage_Script_Name"] + +} diff --git a/templates/vsm_vm.xml.erb b/templates/vsm_vm.xml.erb new file mode 100644 index 0000000..74d017e --- /dev/null +++ b/templates/vsm_vm.xml.erb @@ -0,0 +1,86 @@ + + <%= scope.lookupvar('n1k_vsm::vsmname') %> + <%= scope.lookupvar('n1k_vsm::memory') %> + <%= scope.lookupvar('n1k_vsm::vcpu') %> + + + hvm + + + + + + + + destroy + restart + restart + + + /usr/libexec/qemu-kvm + + + '/> + + + + + + '/> + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +
+ + + + + + + + +