Unnamed poster,

Succinctly: You're trying to write a bash script in Puppet. That's not
how it works, that's not what it's designed for, that's not how it
should be used.

However, luckily, there's a really simple and easy way to do what you're
trying to in Puppet:

    Class['myapp::phase1'] -> Class['myapp::phase2'] ->
Class['myapp::phase3']

If there are *specific* things that you need to make sure happen before
a given action (like making sure a package is installed before a config
file is created/changed), that's what "requires" is for.

You may want to refer to John Bollinger's 2014-01-03 reply to the
"wondering if I want to[sic] much now" thread, which gives some
excellent descriptions on 'how not to Puppet':
https://groups.google.com/d/msg/puppet-users/IGqjPpVCrKA/VcUKiV3xfPkJ

-Jason

On 02/04/2014 06:11 PM, [email protected] wrote:
> Hi, im trying to work some logic into a puppet class and I'm not sure
> the best way to do it.  For this application, I have an installation
> phase, a setup phase, and then a maintenance phase.
>
> My current method of maintaining this is to call the relevant subclass
> using "include".  I then  have to go comment out two of the 3 includes
> depending on which phase i'm on.  This of course means that I have to
> shut off puppet on all the nodes im not directly working on.
>
> I would like to use the following logic in my class to control this. 
> Could somebody help me with the proper syntax to get this working?
>
>
> class myapp {
>
>   Class['myapp::phase1'] only if [ ! -e /path/to/puppet.phase ]
>     # myapp::phase1 will echo 'phase2' into /path/to/puppet.phase 
> once all requirements are met
>
>   Class['myapp::phase2'] only if [ $(cat /path/to/puppet.phase) ==
> 'phase2' ]
>     # myapp::phase2 will echo 'phase3' into /path/to/puppet.phase 
> once all requirements are met
>
>   Class['myapp::phase3'] only if [ $(cat /path/to/puppet.phase) ==
> 'phase3' ]
> }
>
> -- 
> 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/2c4124a2-dfd1-4006-b5c0-b66e026dfe5e%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 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/52F22996.9040704%40jasonantman.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to