Own Package Installscript

36 views
Skip to first unread message

daniel.r...@googlemail.com

unread,
Nov 12, 2013, 8:31:55 AM11/12/13
to puppet...@googlegroups.com
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

Matthaus Owens

unread,
Nov 12, 2013, 11:51:20 AM11/12/13
to puppet...@googlegroups.com
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
--
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...@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
Reply all
Reply to author
Forward
0 new messages