Hi Martin,

Thanks for your help. I have tried your hack but didn't work, still same 
error,
class addfile ( 
  $enable_notify => Service[’tomcat’], 
) { 
  file {‘/tmp/hello’: 
    ensure => file, 
    notify => $enable_notify,
  }
}

Technically, we can all any resource from any classes since all resources 
are unique across modules.

Thanks,
Afroz Hussain

On Thursday, 31 March 2016 17:40:27 UTC+5:30, Martin Alfke wrote:
>
> Hi Arfoz, 
>
> this is the best example on how to _not_ do classes. 
> Every class should be self contained - as long as possible. 
> In your case you have a hard reference from one resource inside a class to 
> another resource inside another class. 
> I always tell my training course attendees that they should never do this 
> unless they don’t like themselves and they want to have Puppet nightmares. 
>
> In your case you can do the following hack: 
>
> make the add file class a parameterised class, set the parameter to the 
> default behaviour: 
>
> class addfile ( 
>   $enable_notify => Service[’tomcat’], 
> ) { 
>   file {‘/tmp/hello’: 
>     ensure => file, 
>     notify => $enable_notify, 
>   } 
> } 
>
> On systems where you don’t have tomcat class included you have to declare 
> the class add file with parameter set to undef. 
>
> But: be aware that even this is not a good solution. 
> It’s just a hack. 
> Try to refacter your modules. 
>
> Best, 
> Martin 
>
>
> On 31 Mar 2016, at 13:48, Afroz Hussain <hussai...@gmail.com <javascript:>> 
> wrote: 
>
> > Error as below: 
> > 
> > Error: Could not retrieve catalog from remote server: Error 400 on 
> SERVER: Invalid relationship: File[/tmp/hello] { notify => Service[tomcat] 
> }, because Service[tomcat] doesn't seem to be in the catalog 
> > 
> > On Thursday, 31 March 2016 17:13:46 UTC+5:30, Afroz Hussain wrote: 
> > Hi All, 
> > 
> > I am facing an issue to notify a service from different module whenever 
> file changes. 
> > Example: 
> > I have a addfile module which creates a file and want to notify tomcat 
> service which is present in tomcat module. 
> > 
> > class addfile { 
> >    file {"/tmp/hello": 
> >      ensure => file, 
> >      content => "hello", 
> >      notify   => Service["tomcat'], 
> >    } 
> > } 
> > 
> > 
> > it is throwing an error as tomcat service is not in catalog. 
> > 
> > I have 3.6.2 version of puppet and using ENC. 
> > 
> > Any help will be appreciated 
> > 
> > Thanks, 
> > Afroz Hussain 
> > 
> > 
> > -- 
> > 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 <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/02cfc06d-d306-48a2-a917-7144606a1509%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d2a5cdb9-e49d-46eb-a67d-c650dae895b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to