Sorry, to copy the code has emerged a small error: custom_functions.pp:
define superservice ($initscript, $filecontrol) { On 12 mar, 09:51, Antonio Xanxess <antonio.sanchez.agui...@gmail.com> wrote: > Hi Christian, thanks for the comment. I will explain more carefully > the case so all of the data. > My goal is to happen to subscribe clause with a variable proper > syntax, because the resource service I have defined as a function. For > my needs I created a specific function, make the process of generating > the string you must enter the clause subscribe. I show first the role > of the manifest, this is is in a class of its own that I called > custom_functions.pp: > > superservice defined ($initscript, $filecontrol) { > $pattern = modelo_suscribe( "$filecontrol") > package { $title: ensure => installed } > service {$initscript: > ensure => true, > enable => true, > subscribe => [$model] > } > > } > > modelo_suscribe is the proper role of Ruby that make this process: > > module Puppet::Parser::Functions > NewFunction (:modelo_suscribe,:type =>:rvalue) do | args | > string = args[0] > array = cadena.split(",") > str = "" > array.each do |element| > str_tmp = "File[\"# (element)\"]," > str = str + str_tmp > end > str = str.chomp(",") > return str > end > end > > And last stop superservice call the function on the manifest, for > apache2 service for example, would be called like this: > > superservice {apache2: > initscript => "apache2" > filecontrol => "/etc/apache2/sites-available/ssl,/etc/ > apache2/apache.pem,/etc/apache2/sites-available/default,/etc/apache2/ > ports.conf " > } > > I debugging the server and get the following: > debug:Scope(Custom_functions:Superservice[apache2]):File["/etc/apache2/ > sites-available/ssl"], File["/etc/apache2/apache.pem"], File ["/etc/ > apache2/sites-available/default"], File["/etc/apache2/ports.conf"] > > And the client side you see the same error. > warning: Configuration could not be instantiated: Parameter subscribe > failed: Relationships must be resource references at /etc/puppet/ > manifests/classes/custom_functions.pp: 71; using cached catalog > > I reviewed what I've mentioned, but understand what the term > definition files. As I have created a specific function for service, I > created one for file, because I need to make checks before setting the > file, then in the case of manifest apache2 would be: > class apache2 inherits base { > > superpackage { openssl: } > > superfile { "/etc/apache2/sites-available/ssl": > service => apache2 > } > ... > > As I really do not define the files with "file" but I've created > "superfile", which first performs a check and then define file for > files. Can this influence the behavior of puppet? > > Thanks and regards > > On 12 mar, 08:40, christian <christ...@cust.in> wrote: > > > > > I don't think that that's gonna work... > > As the error message says subscribe needs a resource reference which > > means that you need something like File["myfile"]. > > > What is it exactly that you want to do? > > You want to start a service after 2 files being created/changed? > > Then you should try something like subscribe => [File["file1"], > > File["file2"]] > > And of course you need to define file1 and file2 as well ;) > > > In your actual manifest are there whitespaces between the "$" and the > > variablename, too? > > This may also cause some syntax problems, I guess. > > > On 11 Mrz., 17:51, Antonio Xanxess <antonio.sanchez.agui...@gmail.com> > > wrote: > > > > Hello! I'm trying to create a resource of type service in which there > > > is a clause subscribe. In this clause need to put a variable, and when > > > I run the client gives me this error: > > > warning: Configuration could not be instantiated: Parameter subscribe > > > failed: Relationships must be resource references at / etc / puppet / > > > manifests / classes / custom_functions.pp: 73; using cached catalog > > > Then you expose the piece of code and see if you have idea why this > > > happens. > > > > service ($ title: > > > ensure => true, > > > enable => true, > > > subscribe => [$ model] > > > ) > > > > The variable $ model returns the following: > > > debug: Scope (Custom_functions: Superservice [apache2]) File [ "/ etc/ > > > apache2/sites-available/ssl"], File [ "/ etc/apache2/apache.pem"] > > > > It is possible that the clause does not support variables subscribe? > > > I've been looking all over the Internet and have not found the answer. > > > > Thanks for everything, greetings. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.