Ask Your Question

How to create a class that only refresh

asked 2017-11-17 07:40:58 -0600

It is possible to create a class that only executes when receives a notification event? I want to do exactly what exec does with "refreshonly", I could not find how to do this. Specifically, what I want to do is:

I have an archive resource, that downloads a file, with a "create" attribute:

archive { "/opt/service/service-${version}.jar":
    source        => "http://[ARTIFACT_URL]/service-${version}.jar",
    creates       => "/opt/service/service-${version}.jar",
    cleanup       => false,

I would like to do this:

Archive["/opt/service/service-${version}.jar"] ~> Some_custom_class['some_title']

But "Somecustomclass" can only execute when the archive downloads the file, that is when a notification event is triggered.


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2017-11-17 15:44:19 -0600

updated 2017-11-17 15:44:55 -0600

There's no such thing as Some_custom_class. You probably meant Class['module_name']. An upper-case initial marks a reference (a “pointer”).

Notifying a class forwards the refresh event to all contained resources: PP doc: relationships § “receiving refresh events”

Ergo, you have to specify refreshonly => true along all Exec resources your Class['module_name'] declares. Then they'll only fire if they (or their surrounding class) receive a notification.

As with Exec resources, you can't achieve a behavior, making your class only existent if it's received a notification. The class's always either there or not there, declared or not defined.

edit flag offensive delete link more


You are right, I miss the syntax but it is exactly what I meant. I've read this page, but it was not clear to me that it is impossible. Thank you!

alexferreira21 gravatar imagealexferreira21 ( 2017-11-17 16:07:34 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-11-17 07:40:58 -0600

Seen: 125 times

Last updated: Nov 17 '17