On Apr 25, 10:02 pm, Suresh <[email protected]> wrote:
> class filecheck {
>   include myapp
>   file { "puppet:///modules/myapp/MyApp_GA.tar.gz":
>     owner => 'myapp',
>     group => 'myapp',
>     ensure => latest,
>     path => "/opt/apps/myapp/artifacts/MyApp_GA.tar.gz",
>   }
>
> }
>
> class myapp::decompress {
>   exec { "myapp::decompress":
>     owner => 'myapp',
>     group => 'myapp',
>     mode => 0755,
>     command => "/bin/tar -xzf MyApp_GA.tar.gz -C /opt/apps/myapp/release"
>
> }
>
> in my puppet manifests/nodes.pp
> I have defined several stages e.g.
>
> nodes.pp
> ========
> stage {
>   "stop_service": ;
>  }
>
>  node mynode.com {
>    include filecheck, myapp
>  }
>
> What I need is if filecheck fails, then execution should stop and should go
> no further.


That should indeed happen if filecheck failed, but File['puppet:///
modules/myapp/MyApp_GA.tar.gz'] (and thus Class['filecheck']) will not
fail on account of the file already being present.  It should not
download the file again either in that case (are you sure it's doing
so?) unless the version on the server is different from the one on the
client, but nothing I see in your manifests would prevent Puppet from
proceeding to Exec[ 'myapp::decompress' ].

You need to adjust your mental model.  Your class names and your
expectations suggest that you regard Puppet as some kind of scripting
engine.  It isn't.  Rather, it is a state management service.  It
takes your specifications for a target *state*, and does whatever is
necessary (broadly speaking) to achieve that state.  "Whatever it
takes" can be nothing, and that's just fine with Puppet -- by no means
is it a failure.

To address your problem, it would be far better build a package for
"myapp" (RPM, DEB, or whatever is appropriate for your target system),
put it in a local package repository, and use Puppet's Package
resource type to ensure it installed.  Even stopping and restarting
the service around an installation or update would be better done in
the package's scripts than directly under Puppet control.  Don't
reinvent the wheel here.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to