If you’re trying to run an exec, you can do this:

file { ‘/tmp/test’:
        ensure  => present,
        content => ‘Hello’,
        notify    => Exec[‘after’],
}

exec { ‘after’:
        command   => ‘/bin/echo Created’,
        refreshonly => true,
}

subscribe on the exec vs notify on the file works as well as does the chaining 
arrow.  To me, notify is easier to read but you can mix and match as well.  I 
think the refreshonly parameter is only available on the exec resource, but you 
can also notify other resources such as services which will restart the 
service.  There are some resources it doesn’t make sense to notify such as 
files since the actual file is being validated/updated every puppet run 
regardless of what is happening with any other resource.

On Nov 19, 2013, at 1:40 AM, [email protected] wrote:

> Hi! 
> I need to create manifest that creates file and run some command on it's 
> change. I thought that I can do it with subscribe and notify statements, but 
> I can't. Can someone give me example of such manifest?
> I tried using manifest like this, and it always displays notify message, 
> despite the fact that file has not changed
>         file { '/tmp/test':
>                 ensure => present,
>                 content => "Hello",
>         }
>        notify {'after':
>                message => "File created",
>                subscribe => File['/tmp/test/'],
>        }
> File['/tmp/test'] ~> Notify['after']
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" 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-dev/a839b7ee-c1bc-40fb-a2a1-b56d47b1d415%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" 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-dev/A9CD767B-882C-4CD2-93BA-31D97261C8F7%40infiniteviewtech.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to