daniel.richardt89@googlemail.com
2013-Nov-12 13:31 UTC
[Puppet Users] Own Package Installscript
Hi, i want to use Puppet to install all packages from a webserver (no repository) . Therefore I wrote following Script: class install_package { case "$operatingsystem" { SLES: { notify {"${operatingsystem} ${operatingsystemrelease} detected":} notify {"Installing $packagename now:":} exec { ''installing $packagename'': command => "rpm -iv ${repopath}${packagename}", path => ["/usr/bin", "/usr/sbin", "/bin"] } } } } The Script works perfekt if the Variables are inside the Script. Now I want to use this class for Building a tomcat server. In this case I have to use the class 2 times. I tried to change the contend of the variable , but I only get error. I see no functioning possibility to use the class 2 times and to give them the Variables $packagename and $repopath.(packagename changing ) I tried to use it in a parametrezied class as following: class tomcat { class {''install_package'': packagename => "mypackage.rpm", repopath => "http://www.something.de", } class {''install_package'': packagename => "mypackagename2.rpm", repopath => "http://www.something.de", } } class install_package { case "$operatingsystem" { SLES: { notify {"${operatingsystem} ${operatingsystemrelease} detected":} notify {"Installing $packagename now:":} exec { ''installing $packagename'': command => "rpm -iv ${repopath}${packagename}", path => ["/usr/bin", "/usr/sbin", "/bin"] } } } } that wars also not possible. I I have no idea anymore. Pls help me -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/ff6c1dcb-3787-4e78-b472-fc2e7f6c62ec%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
You can only have one instance of a class in a catalog. It sounds like a defined type would suit your use case better. Defined types can be used multiple times in the same catalog as long as they have unique names and don''t themselves create duplicate resources. http://docs.puppetlabs.com/learning/definedtypes.html is a good place to start for more information. HTH On Tuesday, November 12, 2013, wrote:> Hi, > i want to use Puppet to install all packages from a webserver (no > repository) . > Therefore I wrote following Script: > > class install_package { > case "$operatingsystem" { > SLES: { > > notify {"${operatingsystem} > ${operatingsystemrelease} detected":} > notify {"Installing $packagename now:":} > exec { ''installing $packagename'': > command => "rpm -iv > ${repopath}${packagename}", > path => ["/usr/bin", "/usr/sbin", "/bin"] > } > > } > } > } > > The Script works perfekt if the Variables are inside the Script. > Now I want to use this class for Building a tomcat server. > In this case I have to use the class 2 times. > I tried to change the contend of the variable , but I only get error. > > I see no functioning possibility to use the class 2 times and to give them > the Variables $packagename and $repopath.(packagename changing ) > > I tried to use it in a parametrezied class as following: > > class tomcat { > class {''install_package'': > packagename => "mypackage.rpm", > repopath => "http://www.something.de", > } > > class {''install_package'': > packagename => "mypackagename2.rpm", > repopath => "http://www.something.de", > } > > } > > class install_package { > case "$operatingsystem" { > SLES: { > > notify {"${operatingsystem} > ${operatingsystemrelease} detected":} > notify {"Installing $packagename now:":} > exec { ''installing $packagename'': > command => "rpm -iv > ${repopath}${packagename}", > path => ["/usr/bin", "/usr/sbin", "/bin"] > } > > } > } > } > > that wars also not possible. I > I have no idea anymore. Pls help me > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscribe@googlegroups.com <javascript:_e({}, > ''cvml'', ''puppet-users%2Bunsubscribe@googlegroups.com'');>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/ff6c1dcb-3787-4e78-b472-fc2e7f6c62ec%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- Matthaus Owens Release Manager, Puppet Labs Join us at PuppetConf 2014, September 23-24 in San Francisco -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CACD%3DwAd7LS359Sw7nuyrQnTUn8H6rwjatk5ukSJ3pRC03ToQmg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.