> On 20 Dec 2016, at 17:35, Larry Jacobson <[email protected]> wrote:
> 
> I want to update a service on a server (server B) when a file changes on a 
> different server (serverA).  I am using stored configs with puppetdb.  
> When I do something like the code below I get the following error message
> 
> Error 400 on SERVER: Invalid relationship: File[/etc/test.txt] { notify => 
> Exec[command_on different_server] }, because Exec[command_on 
> different_server] is exported but not collected
> 
> Am I on the right track?  I can't seem to figure it out how to do this.

You are on the right track.
Maybe the following will work:

class server_a::configfile {
  file { ‘/etc/text.txt’:
    ensure => file,
    ...
  }
}

class server_a::command {
  @@exec { ‘run command’:
    tag => ‘command’,
    …
  }
}

class server_a {
  contain server_a::configfile
  contain server_a::command

  Class[‘server_a::configfile’] ~> Class[‘server_a::command’]
}

class server_b {
  Exec <<| tag == ‘command’ |>>
}

The ~> notify/subscribe chaining on the class will propagate the 
notify/subscribe to the resources inside the class.


> 
> 
> 
> class serverA {
> 
>     file { "/etc/test.txt":
>                 mode => 644,
>                 source => "puppet:///modules/nagios/test.txt",
>                 notify => Exec["command_on different_server"],
> 
>      }
> 
>     @@exec { "command_on_different_server":
>          command => "/usr/bin/command_whaterver",
>          tag => "tag_command",
>      }
> }
> =====================
> 
> class serverB {
> 
>          Exec <<| tag == "tag_command" |>> {}
> 
> }
> 
>      
> 
> 
> 
> 
> -- 
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/62a9eb9d-fd73-4dea-8d35-b74211b20e6b%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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/EB4FEF36-DD2F-469E-B5B4-B31CC9796FBE%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to