diff --git a/manifests/deploy.pp b/manifests/deploy.pp index 02e8898..b39afe6 100644 --- a/manifests/deploy.pp +++ b/manifests/deploy.pp @@ -1,36 +1,21 @@ # == Class: n1k_vsm::deploy # # This class that actually deploys a VSM VM in the server -# -# == Parameters: -# -# == Actions: -# -# == Requires: -# # This depends of n1kv_vsm class to set some environmental variables # -# == Sample Usage: -# class n1k_vsm::deploy { #ensure tap interfaces and deploy the vsm - $ctrltap = 'vsm-ctrl0' - $mgmttap = 'vsm-mgmt0' - $pkttap = 'vsm-pkt0' - - #$diskfile = "/var/spool/vsm/${n1k_vsm::vsm_role}_disk" + $ctrltap = 'vsm-ctrl0' + $mgmttap = 'vsm-mgmt0' + $pkttap = 'vsm-pkt0' exec { 'Exec_create_disk': command => "/usr/bin/qemu-img create -f raw ${n1k_vsm::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 ${n1k_vsm::diskfile} ${n1k_vsm::disksize}G\" >> ${n1k_vsm::Debug_Log}", + unless => "/usr/bin/virsh list --all | grep -c ${n1k_vsm::vsmname}", } - $targetxmlfile = "/var/spool/vsm/vsm_${n1k_vsm::vsm_role}_deploy.xml" + $targetxmlfile = "/var/spool/cisco/vsm/vsm_${n1k_vsm::vsm_role}_deploy.xml" file { 'File_Target_XML_File': path => $targetxmlfile, owner => 'root', @@ -39,28 +24,16 @@ class n1k_vsm::deploy 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} && /usr/bin/virsh autostart ${n1k_vsm::vsmname}", - unless => "/usr/bin/virsh list | grep -c ' ${n1k_vsm::vsmname} '", - } - -> - 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_Define_VSM': + command => "/usr/bin/virsh define ${targetxmlfile}", + unless => "/usr/bin/virsh list --all | grep -c ${n1k_vsm::vsmname}", } 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}", + unless => "/usr/bin/virsh list --all | grep ${n1k_vsm::vsmname} | grep -c running", } - Exec['Exec_create_disk'] -> File['File_Target_XML_File'] -> Exec['Exec_Create_VSM'] -> Exec['Exec_Launch_VSM'] + Exec['Exec_create_disk'] -> File['File_Target_XML_File'] -> Exec['Exec_Define_VSM'] -> Exec['Exec_Launch_VSM'] } diff --git a/manifests/init.pp b/manifests/init.pp index 5a0302a..a9ee4e8 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,102 +1,95 @@ # == Class: n1k_vsm # -# This class deploys a Nexus1000v VSM VEM in a server +# Deploy N1KV VSM as a VM on RHEL7 server. +# Support exists and tested for RedHat. +# (For Ubuntu/Debian platforms few changes and testing pending.) # # == Parameters: # -# [*phy_if_bridge*] - Physical interface used for the bridge to connect outside the node +# [*phy_if_bridge*] +# (required) Physical interface that will be moved to the bridge for mgmt trafic # -# [*phy_gateway*] - IP address of the default gateway for the external interface +# [*phy_gateway*] +# (required) Default gateway for the mgmt network # -# [*vsm_role*] - Role (primary/secondary) of the Nexus1000v VSM +# [*vsm_role*] +# (required) Role (standalone/primary/secondary) of the Nexus1000v VSM # -# [*vsm_domain_id*] - Domain id of the Nexus1000v VSM +# [*vsm_domain_id*] +# (required) Domain id of the Nexus1000v VSM # -# [*vsm_admin_passwd*] - Password of admin user on the Nexus1000v VSM +# [*vsm_admin_passwd*] +# (required) Password of admin user on the Nexus1000v VSM # -# [*vsm_mgmt_ip*] - IP of the management interface on the Nexus1000v VSM +# [*vsm_mgmt_ip*] +# (required) IP of the management interface on the Nexus1000v VSM # -# [*vsm_mgmt_netmask*] - IP netmask of the management interface of the Nexus1000v VSM +# [*vsm_mgmt_netmask*] +# (required) IP netmask of the management interface of the Nexus1000v VSM # -# [*vsm_mgmt_gateway*] - IP of the default gateway for the management interface of the Nexus1000v VSM +# [*vsm_mgmt_gateway*] +# (required) IP of the default gateway for the management interface of the Nexus1000v VSM # -# [*n1kv_source*] - Location where to get the Nexus1000v VSM ISO package +# [*n1kv_source*] +# (required) Location where to get the Nexus1000v VSM ISO/RPM package # -# [*n1kv_version*] - Version of the Nexus1000v VSM -# -# == Actions: -# -# == Requires: -# -# == Sample Usage: +# [*n1kv_version*] +# (required) Version of the Nexus1000v VSM # class n1k_vsm( - $phy_if_bridge = 'enp1s0f0', + $n1kv_source = '', + $n1kv_version = 'latest', + $phy_if_bridge = 'enp1s0f0', $phy_gateway, - $vsm_role = 'primary', + $vsm_role = 'primary', $vsm_domain_id, $vsm_admin_passwd, $vsm_mgmt_ip, $vsm_mgmt_netmask, $vsm_mgmt_gateway, - $n1kv_source = 'puppet:///modules/n1k_vsm/vsm.iso', - $n1kv_version = 'latest' ) { - # - # Network parameters - # - $ovsbridge = 'br-int' - $phy_ip_addr = inline_template("<%= scope.lookupvar('::ipaddress_${n1k_vsm::phy_if_bridge}') %>") - $phy_ip_mask = inline_template("<%= scope.lookupvar('::netmask_${n1k_vsm::phy_if_bridge}') %>") - #$gw_intf = inline_template("<%= scope.lookupvar('::gateway_device') %>") - $gw_intf = $n1k_vsm::phy_gateway - # - # VSM parameters - # - if $n1k_vsm::vsm_role == 'primary' { - $vsmname = 'vsm-p' - $mgmtip = $vsm_mgmt_ip - $mgmtnetmask = $vsm_mgmt_netmask - $mgmtgateway = $vsm_mgmt_gateway - } else { # secondary - $vsmname = 'vsm-s' - $mgmtip = '0.0.0.0' - $mgmtnetmask = '0.0.0.0' - $mgmtgateway = '0.0.0.0' + if($::osfamily != 'Redhat') { + #current support exists for Redhat family. + #Support for Debian will be added soon. + fail("Unsupported osfamily ${::osfamily}") } - $consolepts = 2 - $memory = 4096000 - $vcpu = 2 - $disksize = 4 - $imgfile = "/var/spool/vsm/${n1k_vsm::vsm_role}_repacked.iso" - $diskfile = "/var/spool/vsm/${n1k_vsm::vsm_role}_disk" + if ($n1k_vsm::vsm_role == 'primary') or ($n1k_vsm::vsm_role == 'standalone') { + $vsmname = 'vsm-p' + $mgmtip = $vsm_mgmt_ip + $mgmtnetmask = $vsm_mgmt_netmask + $mgmtgateway = $vsm_mgmt_gateway + } else { # secondary + $vsmname = 'vsm-s' + $mgmtip = '0.0.0.0' + $mgmtnetmask = '0.0.0.0' + $mgmtgateway = '0.0.0.0' + } - $Debug_Print = '/usr/bin/printf' - $Debug_Log = '/tmp/n1kv_vsm_puppet.log' + $consolepts = 2 + $memory = 4096000 + $vcpu = 2 + $disksize = 4 + $imgfile = "/var/spool/cisco/vsm/${n1k_vsm::vsm_role}_repacked.iso" + $diskfile = "/var/spool/cisco/vsm/${n1k_vsm::vsm_role}_disk" + $ovsbridge = 'vsm-br' + + #VSM installation will be done only once. Will not respond to puppet sync + $_phy_ip_addr = inline_template("<%= scope.lookupvar('::ipaddress_${n1k_vsm::phy_if_bridge}') %>") + if $_phy_ip_addr != '' { + $phy_ip_addr = inline_template("<%= scope.lookupvar('::ipaddress_${n1k_vsm::phy_if_bridge}') %>") + $phy_ip_mask = inline_template("<%= scope.lookupvar('::netmask_${n1k_vsm::phy_if_bridge}') %>") + $gw_intf = $n1k_vsm::phy_gateway + include n1k_vsm::pkgprep_ovscfg + } notify {"Arg: intf ${phy_if_bridge} vsm_role ${vsm_role} domainid ${vsm_domain_id}" : withpath => true} notify {"ip ${phy_ip_addr} mask ${phy_ip_mask} gw ${n1k_vsm::phy_gateway}" : withpath => true} notify {"gw_dv ${gw_intf} ovs ${ovsbridge} vsmname ${n1k_vsm::vsmname}" : withpath => true} notify {"mgmtip ${n1k_vsm::mgmtip} vsm_mask ${n1k_vsm::mgmtnetmask} vsm_gw ${n1k_vsm::mgmtgateway}": withpath => false} - - # - # Clean up debug log - # - file {"File_${Debug_Log}": - ensure => 'absent', - path => $Debug_Log, -# } -> -# file_line { "Adding info to debug": -# path => $Debug_Log, -# line => "phy ${n1k_vsm::phy_if_bridge} ip ${n1k_vsm::phy_ip_addr} gw ${n1k_vsm:phy_gateway}", - } - - 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'] + Class['n1k_vsm::vsmprep'] -> Class['n1k_vsm::deploy'] } diff --git a/manifests/pkgprep_ovscfg.pp b/manifests/pkgprep_ovscfg.pp index 0abc627..96253e0 100644 --- a/manifests/pkgprep_ovscfg.pp +++ b/manifests/pkgprep_ovscfg.pp @@ -1,161 +1,81 @@ # == Class: n1k_vsm::pkgprep_ovscfg -# # This class prepares the packages and ovs bridge for the VSM VM -# -# == Parameters: -# -# None -# -# == Actions: -# -# == Requires: -# # This requires n1k_vsm class to set some environmental variables # -# == Sample Usage: -# class n1k_vsm::pkgprep_ovscfg { require n1k_vsm include n1k_vsm - # 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': ensure => running, name => 'network', 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 - # package { 'Package_qemu-kvm': ensure => installed, name => 'qemu-kvm', - 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_libvirt': ensure => installed, name => 'libvirt', - 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': ensure => installed, name => 'libvirt-python', - 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_ebtables': ensure => installed, name => 'ebtables', - 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': ensure => running, name => 'libvirtd', } - -> - 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': ensure => installed, name => 'openvswitch', } - -> - 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': ensure => running, name => 'openvswitch', 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}", -# } + package { 'genisoimage': + ensure => installed, + name => 'genisoimage', + } notify { "Debug br ${n1k_vsm::ovsbridge} intf ${n1k_vsm::phy_if_bridge} ." : withpath => true } notify { "Debug ${n1k_vsm::vsmname} ip ${n1k_vsm::phy_ip_addr} mask ${n1k_vsm::phy_ip_mask} gw_intf ${n1k_vsm::gw_intf}" : withpath => true } # Check if we've already configured the ovs if $n1k_vsm::gw_intf != $n1k_vsm::ovsbridge { - # # 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}", @@ -175,16 +95,9 @@ class n1k_vsm::pkgprep_ovscfg "set GATEWAY ${n1k_vsm::phy_gateway}", 'set USERCTL no', ], - #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-phy_if_bridge': name => $n1k_vsm::phy_if_bridge, context => "/files/etc/sysconfig/network-scripts/ifcfg-${n1k_vsm::phy_if_bridge}", @@ -204,17 +117,7 @@ class n1k_vsm::pkgprep_ovscfg ], notify => Service['Service_network'], } -# -> -# exec { 'Add default route': -# command => "/sbin/route add default gw ${n1k_vsm::phy_gw_ip} ${n1k_vsm::ovsbridge}", -# } - -> - exec { 'Debug_Augeas_modify_ifcfg-phy_if_bridge': - command => "${n1k_vsm::Debug_Print} \"[INFO]\n Augeas_modify_ifcfg-phy_if_bridge \n name=${n1k_vsm::phy_if_bridge} \n context=/files/etc/sysconfig/network-scripts/ifcfg-${n1k_vsm::phy_if_bridge}\n\" >> ${n1k_vsm::Debug_Log}", - } - # # Make sure that networking comes fine after reboot - # file { 'Create_Init_File': replace => 'yes', path => '/etc/init.d/n1kv', @@ -222,32 +125,14 @@ class n1k_vsm::pkgprep_ovscfg group => 'root', mode => '0775', source => 'puppet:///modules/n1k_vsm/n1kv', -# content => '#!/bin/sh \n\n/etc/init.d/network restart \n/usr/lib/systemd/system/libvirtd.service restart \n\n', - } - -> - exec { 'Debug_File_Init': - command => '/usr/bin/ln -s /etc/init.d/n1kv /etc/rc.d/rc3.d/S98n1kv', } } # endif of if "${n1k_vsm::gw_intf}" != "${n1k_vsm::ovsbridge}" - - # - # Order enforcement logic - # - if $n1k_vsm::gw_intf != $n1k_vsm::ovsbridge { - Notify[$Sync_Point_KVM]->Service['Service_libvirtd']->Notify[$Sync_Point_Virsh_Network]->Package['Package_openvswitch']->Service['Service_openvswitch']->Augeas['Augeas_modify_ifcfg-ovsbridge']->Augeas['Augeas_modify_ifcfg-phy_if_bridge']->File['Create_Init_File'] -#->Exec["Exec_rebridge"] - } else { - Notify[$Sync_Point_KVM]->Service['Service_libvirtd']->Notify[$Sync_Point_Virsh_Network]->Package['Package_openvswitch']->Service['Service_openvswitch'] - } } 'Ubuntu': { } default: { - # # bail out for unsupported OS - # fail(": os[${::os}] is not supported") } } } - diff --git a/manifests/vsmprep.pp b/manifests/vsmprep.pp index 4d64704..3244702 100644 --- a/manifests/vsmprep.pp +++ b/manifests/vsmprep.pp @@ -1,18 +1,7 @@ # == Class: n1k_vsm::vsmprep # # This class prepares the VSM image to be deploy in a server -# -# == Parameters: -# -# None -# -# == Actions: -# -# == Requires: -# -# This class requires n1kv_vsm to set some environmental variables -# -# == Sample Usage: +# This class requires n1k_vsm to set some environmental variables # class n1k_vsm::vsmprep { @@ -20,173 +9,79 @@ class n1k_vsm::vsmprep require n1k_vsm include n1k_vsm - # - # VSM package source parsing logic - # - $source = $n1k_vsm::n1kv_source - - $sourcemethod = regsubst($source, '^(.+):.*', '\1') - $dest = inline_template('<%= File.basename(source) %>') - - - $VSM_Bin_Prepare_Sync_Point='##VSM_BIN_PREPARE_SYNC_POINT' - $VSM_Spool_Dir='/var/spool/cisco/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 folders - # - file { 'File_VSM_Spool_Dir': + ensure_resource('file', '/var/spool/cisco/', { ensure => directory, - path => $VSM_Spool_Dir, owner => 'root', group => 'root', - mode => '0664', - } - -> - 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}", - } - - file { 'File_VSM_RPM_Dir': + mode => '0664'} + ) + ensure_resource('file', '/var/spool/cisco/vsm', { ensure => directory, - path => $VSM_RPM_Install_Dir, owner => 'root', group => 'root', - mode => '0664', - } - -> - exec { 'Debug_File_VSM_RPM_Dir': - command => "${n1k_vsm::Debug_Print} \"[INFO]\n File_VSM_RPM_Install_Dir\n path=${VSM_RPM_Install_Dir} \n ensure=directory \n owner=root \n group=root \n mode=664 \n\" >> ${n1k_vsm::Debug_Log}", + mode => '0664'} + ) + + #Check source of n1kv-vsm image:yum-repo (or) local file in 'files' directory + if $n1k_vsm::n1kv_source != '' { + if ($n1k_vsm::n1kv_source =~ /^http/) or ($n1k_vsm::n1kv_source =~ /^ftp/) { + $vsmimage_uri = 'repo' + $vsm_path = '/opt/cisco/vsm' + } else { + $vsmimage_uri = 'file' + $vsmtgtimg = "/var/spool/cisco/vsm/${n1k_vsm::n1kv_source}" + $vsm_path = '/var/spool/cisco/vsm' + } + } else { + $vsmimage_uri = 'unspec' } - case $sourcemethod { - http: { - yumrepo { 'http-cisco-foreman': +# exec { 'Prev_VSM': +# command => "/bin/rm -f /var/spool/cisco/vsm/* || /bin/true", +# } + + if $vsmimage_uri == 'file' { + #specify location on target-host where image file will be downloaded to. + file { $vsmtgtimg: + owner => 'root', + group => 'root', + mode => '0664', + source => "puppet:///modules/n1k_vsm/${n1k_vsm::n1kv_source}", + require => File['/var/spool/cisco/vsm/'], + } + } else { + if $vsmimage_uri == 'repo' { + #vsm package: 'nexus-1000v-vsm' rpm will be downloaded and installed + #from below repo. + yumrepo { 'cisco-vsm-repo': baseurl => $n1k_vsm::n1kv_source, - descr => 'Internal repo for Foreman', + descr => 'Repo for VSM Image', enabled => 1, gpgcheck => 1, - proxy => '_none_', gpgkey => "${n1k_vsm::n1kv_source}/RPM-GPG-KEY", } - -> - package { 'Package_VSM': + } + package {'nexus-1000v-iso': ensure => $n1k_vsm::n1kv_version, - name => $VSM_PKG_NAME, - } - -> - 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': - ensure => installed, - name => 'ftp', - } - -> - 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': - ensure => $n1k_vsm::n1kv_version, - name => $VSM_PKG_NAME, - } - -> - 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': - ensure => present, - path => $VSM_DEST, - owner => 'root', - group => 'root', - mode => '0664', - 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 [${sourcemethod}] is not supported") + name => 'nexus-1000v-iso' } } - notify { $VSM_Bin_Prepare_Sync_Point :} - - # # copy repackiso.py to local place - # - file { 'File_VSM_Repackage_Script_Name': + file { 'VSM_Repackage_Script': ensure => present, - path => $VSM_Repackage_Script, + path => '/tmp/repackiso.py', owner => 'root', group => 'root', mode => '0774', - 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}", + source => 'puppet:///modules/n1k_vsm/repackiso.py', } - # # 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::vsm_domain_id} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role} -f${VSM_Spool_Dir}/${n1k_vsm::vsm_role}_repacked.iso >> ${n1k_vsm::Debug_Log}", + exec { 'Exec_VSM_Repackage_Script': + command => "/tmp/repackiso.py -i/var/spool/cisco/vsm/${n1k_vsm::n1kv_version}.iso -d${n1k_vsm::vsm_domain_id} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role} -f/var/spool/cisco/vsm/${n1k_vsm::vsm_role}_repacked.iso ", + unless => "/usr/bin/virsh list --all | grep -c ${n1k_vsm::vsmname}", } - -> - 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::vsm_domain_id} -n${n1k_vsm::vsmname} -m${n1k_vsm::mgmtip} -s${n1k_vsm::mgmtnetmask} -g${n1k_vsm::mgmtgateway} -p${n1k_vsm::vsm_admin_passwd} -r${n1k_vsm::vsm_role} -f${VSM_Spool_Dir}/${n1k_vsm::vsm_role}_repacked.iso \n\" >> ${n1k_vsm::Debug_Log}" - } - - File['File_VSM_Spool_Dir']->File['File_RPM_Install_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 index 74d017e..9d6c500 100644 --- a/templates/vsm_vm.xml.erb +++ b/templates/vsm_vm.xml.erb @@ -4,7 +4,7 @@ <%= scope.lookupvar('n1k_vsm::vcpu') %> - hvm + hvm @@ -37,8 +37,7 @@ - - + '/> @@ -46,8 +45,7 @@ - - + '/> @@ -55,8 +53,7 @@ - - + '/>