On 5/15/17 9:28 PM, Ugo Bellavance wrote:
> Hi,
> 
> I'm working on a public puppet module and while I've done a lot of
> improvements up to now (especially considering my puppet capabilities),
> there is still a lot of work to do and I'd need some help for my next
> step.  My repo is https://github.com/ubellavance/ZendServerPuppet and my
> next target is to make sure that an application action is not done
> before the bootstrap is complete.  Explanations: the module performs a
> "bootstrap" process at the first puppet run (just after installing the
> packages).  If I set an application action (define, for example) before
> the bootstrap process is complete (which would obviously happen), there
> is an error with obscure error messages provided by the Zend Server API,
> which isn't really user-friendly and it causes a failure of the puppet
> run.  There is a fact that is set to true if the bootstrap is complete:
> $::zend_gui_completed.  I tried doing a conditional statement using this
> variable but I don't know how to just do nothing for the application
> action and just output a message (notify) saying that the application
> actions will be applied after the bootstrap. It is a bit tricky because
> before the bootstrap it doesn't exist, so it is undefined, and once the
> bootstrap is complete, it equals to true.
> 
> I tried this, in application.pp, but it looks like the if doesn't work
> because the notify occurs every time
> 
>   if $::zend_gui_completed != true {____
> 
>     notify {"zend_gui_completed = $::zend_gui_completed. Bootstrap must
> run first. Application settings will be applied after Bootstrap is
> done": }____
> 
>   }
> 
> 
> Here's the output:
> 
> 
> Notice:
> /Stage[main]/Main/Node[default]/Zendserver::Application[patate]/Notify[zend_gui_completed
> = true. Bootstrap must run first. Application settings will be applied
> after Bootstrap is done]/message: defined 'message' as
> 'zend_gui_completed = true. Bootstrap must run first. Application
> settings will be applied after Bootstrap is done'
> 
> 
> Could someone help me figure out how to make the if work, and, even more
> important, if there is a way to "bypass" the zendserver::application
> blocks if zend_gui_completedis not true?
> 
> 
> Here's my application::define:
> 
> 
>   zendserver::application { 'patate':____
> 
>     ensure   => 'define',____
> 
>     base_url => "http://patate.com <http://patate.com/>",____
> 
>     version  => "2",____
> 
>     logo     => "/usr/share/pixmaps/poweredby.png"____
> 
>     }
> 
> 
> Please let me know if you need more information.  
> 
> 
> Thanks,

Hi,

Your comparison of $::zend_gui_completed is never boolean true, so the
notify always happens. Perhaps your fact is returning a string and not a
boolean. Put this in your code just above the conditional statement.

$zgc_type = inline_template('<%= @zend_gui_completed.class %>')
notify { "zend_gui_completed is type ${zgc_type}": }

If it is a string, check out str2bool() from stdlib[1].

[1] - https://github.com/puppetlabs/puppetlabs-stdlib#str2bool

Best regards,
-g



-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4153b999-d7b3-d4e8-1042-142ccbd7a0dd%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to