puppet-n1k-vsm project files missing

Cisco stackforge/puppet-n1k-vsm misses some files and changes to succesfully start
the puppet-n1k-vsm project. This commit addresses those changes to make sure we
can start committing stuff to this project.

Details of the changes:
- Rake and Gemfile files are needed for gate tests.
- Added the license and Modulefile files
- Changed manifest files to pass lint case and initial Unit Testing.

Change-Id: Ia65c8e09c9388709d1834ec7a4a120dfaef807ed
This commit is contained in:
Marga Millet 2014-09-10 14:20:02 -07:00
parent 69ff094069
commit d4178accc3
11 changed files with 664 additions and 385 deletions

4
.gitreview Normal file
View File

@ -0,0 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=stackforge/puppet-n1k-vsm.git

12
Gemfile Normal file
View File

@ -0,0 +1,12 @@
source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', '~> 0.3.2'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end

175
LICENSE Normal file
View File

@ -0,0 +1,175 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

11
Modulefile Normal file
View File

@ -0,0 +1,11 @@
name 'puppet-n1kv-vsm'
version '0.0.2'
author 'ChingWei Chang, Marga Millet'
license 'Apache License 2.0'
project_page 'https://launchpad.net/puppet-n1k-vsm'
source 'https://github.com/stackforge/puppet-n1k-vsm'
summary 'Puppet module for Cisco Nexus1000v VSM'
description 'Puppet module to install and configure the Nexus1000v Virtual Supervisor module"
dependency 'puppetlabs/vswitch', '>=0.0.9'

7
Rakefile Normal file
View File

@ -0,0 +1,7 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_parameter_defaults')
PuppetLint.configuration.send('disable_autoloader_layout')

5
files/n1kv Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
/etc/init.d/network restart
systemctl start libvirtd.service

View File

@ -1,6 +1,5 @@
#!/usr/bin/python
import shutil, tempfile, os, optparse, logging
import sys
import shutil, tempfile, os, optparse, logging, sys
usage = "usage: %prog [options]"
parser = optparse.OptionParser(usage=usage)
@ -71,6 +70,8 @@ def createOvfEnvXmlFile(domain, gateway, hostname, ip, subnet, password, vsm_mod
st += '<Property oe:key="SvsMode" oe:value="L3" /> \n'
st += '<Property oe:key="Password" oe:value="%s" /> \n' % (password)
st += '<Property oe:key="HARole" oe:value="%s" /> \n' % (vsm_mode)
st += '<Property oe:key="EnableOpenStack" oe:value="True" /> \n'
st += '<Property oe:key="SaveBootVars" oe:value="True" /> \n'
#if vsm_mode == "primary":
# st += '<Property oe:key="HARole" oe:value="%s" /> \n' % (vsm_mode)
#else:
@ -100,25 +101,24 @@ def main():
cret = Command('/bin/mount -o loop -t iso9660 %s %s' % (isoimg, mntdir)).run()
#logger.info("%s %s" % (cret.output, cret.error))
if cret.failed:
print(sys.argv[0], "1 ", cret.output, cret.error)
print(sys.argv[0], "Error: Unable to mount disk ", cret.output, cret.error)
sys.exit(1)
cret = Command('/bin/cp -r %s/* %s' % (mntdir, ddir)).run()
print(sys.argv[0], "2 cwchang X", cret.output, "X", cret.error,"X")
print(sys.argv[0], "Copying files ", cret.output, "X", cret.error,"X")
if cret.failed:
print(sys.argv[0], "2 ", cret.output, cret.error)
print(sys.argv[0], "Error: Unable to copy files ", cret.output, cret.error)
sys.exit(1)
#logger.info("%s %s" % (cret.output, cret.error))
cret = Command('/bin/umount %s' % (mntdir)).run()
if cret.failed:
print(sys.argv[0], "3 ", cret.output, cret.error)
print(sys.argv[0], "Error: Unable to unmont dir ", cret.output, cret.error)
sys.exit(1)
#logger.info("%s %s" % (cret.output, cret.error))
#logger.info("%s %s" % (cret.output, cret.error))
cret = Command('/bin/cp %s %s/ovf-env.xml' % (ovf_f.name, ddir)).run()
if cret.failed:
print(sys.argv[0], "4 ", cret.output, cret.error)
print(sys.argv[0], "Error: Unable to copy ovf file ", cret.output, cret.error)
sys.exit(1)
#logger.info("%s %s" % (cret.output, cret.error))
@ -126,13 +126,13 @@ def main():
if os.path.exists('%s/isolinux/isolinux.bin' % (ddir)):
cret = Command('cd %s; /usr/bin/mkisofs -uid 0 -gid 0 -J -R -A Cisco_Nexus_1000V_VSM -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o %s .' % (ddir, repackediso)).run()
if cret.failed:
print(sys.argv[0],"5 ", cret.output, cret.error)
print(sys.argv[0],"Error: Unable to create isofs ", cret.output, cret.error)
sys.exit(1)
#logger.info("%s %s" % (cret.output, cret.error))
else:
cret = Command('cd %s; /usr/bin/mkisofs -uid 0 -gid 0 -J -R -A Cisco_Nexus_1000V_VSM -b boot/grub/iso9660_stage1_5 -no-emul-boot -boot-load-size 4 -boot-info-table -o %s .' % (ddir, repackediso)).run()
if cret.failed:
print(sys.argv[0], "6 ", cret.output, cret.error)
print(sys.argv[0], "Error: Unable to create isofs grub ", cret.output, cret.error)
sys.exit(1)
#logger.info("%s %s" % (cret.output, cret.error))

View File

@ -1,76 +1,66 @@
class n1k_vsm::deploy {
# == 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'
$ctrltap = $n1k_vsm::ctrlinterface[0]
$ctrlmac = $n1k_vsm::ctrlinterface[1]
$ctrlbridge = $n1k_vsm::ctrlinterface[2]
$mgmttap = $n1k_vsm::mgmtinterface[0]
$mgmtmac = $n1k_vsm::mgmtinterface[1]
$mgmtbridge = $n1k_vsm::mgmtinterface[2]
$pkttap = $n1k_vsm::pktinterface[0]
$pktmac = $n1k_vsm::pktinterface[1]
$pktbridge = $n1k_vsm::pktinterface[2]
#$diskfile = "/var/spool/vsm/${n1k_vsm::vsm_role}_disk"
# tapint {"$ctrltap":
# bridge => $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 { '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 $diskfile ${n1k_vsm::disksize}G\" >> ${n1k_vsm::Debug_Log}",
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}",
}
$targetxmlfile = "/var/spool/vsm/vsm_${n1k_vsm::role}_deploy.xml"
file { "File_Target_XML_File":
path => "$targetxmlfile",
owner => 'root',
group => 'root',
mode => '666',
$targetxmlfile = "/var/spool/vsm/vsm_${n1k_vsm::vsm_role}_deploy.xml"
file { 'File_Target_XML_File':
path => $targetxmlfile,
owner => 'root',
group => 'root',
mode => '0666',
content => template('n1k_vsm/vsm_vm.xml.erb'),
require => Exec["Exec_create_disk"],
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 { '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 { '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 { '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 { '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":
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"]
Exec['Exec_create_disk'] -> File['File_Target_XML_File'] -> Exec['Exec_Create_VSM'] -> Exec['Exec_Launch_VSM']
}

View File

@ -1,46 +1,102 @@
# == Class: n1k_vsm
#
# This class deploys a Nexus1000v VSM VEM in a server
#
# == Parameters:
#
# [*phy_if_bridge*] - Physical interface used for the bridge to connect outside the node
#
# [*phy_gateway*] - IP address of the default gateway for the external interface
#
# [*vsm_role*] - Role (primary/secondary) of the Nexus1000v VSM
#
# [*vsm_domain_id*] - Domain id of the Nexus1000v VSM
#
# [*vsm_admin_passwd*] - Password of admin user on the Nexus1000v VSM
#
# [*vsm_mgmt_ip*] - IP of the management interface on the Nexus1000v VSM
#
# [*vsm_mgmt_netmask*] - 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
#
# [*n1kv_source*] - Location where to get the Nexus1000v VSM ISO package
#
# [*n1kv_version*] - Version of the Nexus1000v VSM
#
# == Actions:
#
# == Requires:
#
# == Sample Usage:
#
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",
)
{
$phy_if_bridge = 'enp1s0f0',
$phy_gateway,
$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
$imgfile = "/var/spool/vsm/${role}_repacked.iso"
$diskfile = "/var/spool/vsm/${role}_disk"
#
# 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'
}
$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"
$Debug_Print = '/usr/bin/printf'
$Debug_Log = '/tmp/n1kv_vsm_puppet.log'
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}
$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",
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']
File["File_${Debug_Log}"] -> Class['n1k_vsm::pkgprep_ovscfg'] -> Class['n1k_vsm::vsmprep'] -> Class['n1k_vsm::deploy']
}

View File

@ -1,264 +1,253 @@
class n1k_vsm::pkgprep_ovscfg {
# == 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": {
$Sync_Point_KVM = '##SYNC_POINT_KVM'
$Sync_Point_Virsh_Network = '##SYNC_POINT_VIRSH_NETWORK'
case $::osfamily {
'RedHat': {
#
# Order indepedent resources
# Order indepedent resources
#
service {"Service_network":
name => "network",
ensure => "running",
restart => "/sbin/service network restart || /bin/true",
service { 'Service_network':
ensure => running,
name => 'network',
restart => '/sbin/service network restart || /bin/true',
}
->
exec {"Debug_Service_network":
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"],
package { 'Package_qemu-kvm':
ensure => installed,
name => 'qemu-kvm',
before => Notify[ $Sync_Point_KVM ],
}
->
exec {"Debug_Package_qemu-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"],
package {'Package_libvirt':
ensure => installed,
name => 'libvirt',
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":
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"],
package { 'Package_libvirt-python':
ensure => installed,
name => 'libvirt-python',
before => Notify[ $Sync_Point_KVM ],
}
->
exec {"Debug_Package_libvirt-python":
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"],
package { 'Package_ebtables':
ensure => installed,
name => 'ebtables',
before => Notify[ $Sync_Point_KVM ],
}
->
exec {"Debug_Package_ebtables":
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":}
notify { $Sync_Point_KVM :}
service {"Service_libvirtd":
name => "libvirtd",
ensure => "running",
service { 'Service_libvirtd':
ensure => running,
name => 'libvirtd',
}
->
exec {"Debug_Service_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
# 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 { '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":
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 { '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}",
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",
notify{ $Sync_Point_Virsh_Network :}
package { 'Package_openvswitch':
ensure => installed,
name => 'openvswitch',
}
->
exec {"Debug_Package_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":
name => "openvswitch",
ensure => "running",
enable => "true",
#
# bring up OVS and perform interface configuration
#
service { 'Service_openvswitch':
ensure => running,
name => 'openvswitch',
enable => true,
}
->
exec {"Debug_Service_openvswitch":
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}",
}
# 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}",
}
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 }
#
# 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}",
}
# 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}",
changes => [
'set TYPE OVSBridge',
"set DEVICE ${n1k_vsm::ovsbridge}",
'set DEVICETYPE ovs',
"set OVSREQUIRES ${n1k_vsm::ovsbridge}",
'set NM_CONTROLLED no',
'set BOOTPROTO none',
'set ONBOOT yes',
'set DEFROUTE yes',
'set MTU 1500',
"set NAME ${n1k_vsm::ovsbridge}",
"set IPADDR ${n1k_vsm::phy_ip_addr}",
"set NETMASK ${n1k_vsm::phy_ip_mask}",
"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}",
}
$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}",
}
#
# 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}",
changes => [
'set TYPE OVSPort',
"set DEVICE ${n1k_vsm::phy_if_bridge}",
'set DEVICETYPE ovs',
"set OVS_BRIDGE ${n1k_vsm::ovsbridge}",
'set NM_CONTROLLED no',
'set BOOTPROTO none',
'set ONBOOT yes',
"set NAME ${n1k_vsm::phy_if_bridge}",
'rm IPADDR',
'rm NETMASK',
'rm GATEWAY',
'set USERCTL no',
],
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',
owner => 'root',
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
#
#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"]
#
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": {
'Ubuntu': {
}
default: {
#
# bail out for unsupported OS
#
fail("<Error>: os[$os] is not supported")
fail("<Error>: os[${::os}] is not supported")
}
}
}

View File

@ -1,162 +1,192 @@
class n1k_vsm::vsmprep {
# == 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:
#
class n1k_vsm::vsmprep
{
include 'stdlib'
require n1k_vsm
include n1k_vsm
#
# VSM package source parsing logic
#
$source = $n1k_vsm::n1kv_source
$source_method = regsubst($source, "^(.+):.*", '\1')
$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/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"
$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 spool folder
# prepare vsm folders
#
file {"File_VSM_Spool_Dir":
path => "$VSM_Spool_Dir",
ensure => "directory",
owner => "root",
group => "root",
mode => "664",
file { 'File_VSM_Spool_Dir':
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}",
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':
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}",
}
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",
case $sourcemethod {
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"],
package { 'Package_VSM':
ensure => $n1k_vsm::n1kv_version,
name => $VSM_PKG_NAME,
}
->
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}",
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",
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",
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"],
package { 'Package_VSM':
ensure => $n1k_vsm::n1kv_version,
name => $VSM_PKG_NAME,
}
->
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}",
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": {
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"],
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"],
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":
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"],
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}",
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("<Error>: Unknown sourcing method [$source_method] is not supported")
fail("<Error>: Unknown sourcing method [${sourcemethod}] is not supported")
}
}
notify {"$VSM_Bin_Prepare_Sync_Point":}
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",
file { 'File_VSM_Repackage_Script_Name':
ensure => present,
path => $VSM_Repackage_Script,
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}",
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 { '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 {"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}"
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"]-> Notify["$VSM_Bin_Prepare_Sync_Point"]->File["File_VSM_Repackage_Script_Name"]->Exec["Exec_VSM_Repackage_Script_Name"]
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']
}