On 2014-08-02 06:19, Thom Luxford wrote:
The intention is for the the service running state after boot to be
optionally handled by puppet. Omitting the ensure parameter does this,
but why can't I add it when I need it like this?

service { "$my_module::params::myServiceName":
     if $::my_service_ensure_running != 'undef' {
       ensure  => "$my_module::my_service_ensure_running",
     }
     enable  => 'true',
     require => [ Package["$oscar_legacy::params::mysqlPackageName"],
File["/etc/mysql/conf.d/mysqld_oscar_dbs.cnf"] ],
   }

puppet parser validate {}
complains as so:

Error: Could not parse for environment production: Syntax error at
'::my_service_ensure_running'; expected '}' at
/home/oscara/git/puppetmaster/modules/my_module/manifests/init.pp:154

the "if" is a statement that cannot be used inside a resource definition.

Write it like this:

  service { "$my_module::params::myServiceName":
    enable  => 'true',
    require => [ ...]
  }

  if $::my_service_ensure_running != 'undef' {
    Service["$my_module::params::myServiceName"]{
      ensure  => $::my_service_ensure_running,
    }
  }

See the Puppet Language Reference (http://docs.puppetlabs.com/puppet/latest/reference/lang_conditional.html) for details.


Regards, David

--
* Always looking for people I can help with awesome projects *
G+: https://plus.google.com/+DavidSchmitt
Blog: http://club.black.co.at/log/
LinkedIn: http://at.linkedin.com/in/davidschmitt

--
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/53DF7FF2.6070009%40dasz.at.
For more options, visit https://groups.google.com/d/optout.

Reply via email to