include a class in another class

459 views
Skip to first unread message

Tim Dunphy

unread,
Apr 30, 2015, 11:38:29 PM4/30/15
to puppet...@googlegroups.com
Hey all,
 
 I'd like to include the apache service in my php puppet module. Because when changes are made to the php.ini file, naturally you'll need to bounce apache (if thats your choice of web server) in order for changes to take effect. 

Same thing with adding php modules, etc. 

So in my php puppet module I have this

class php::configure {
   include apache::service

 if $osfamily == "RedHat" {

    file { "/etc/php.ini":
      owner => "root",
      group => "root",
      mode => 0644,
      source => "puppet:///modules/php/php.ini",
      notify => Service["apache::service"],
     }

  }
}

And this:

class php::install {

   include apache::service

  if $osfamily == "RedHat"  {

  case $operatingsystemmajrelease {

.....

"7": {

    package { [ "php", "php-cli", "php-devel", "php-imap", "php-ldap", "php-mysqlnd", "php-mcrypt", "php-xml", "php-gd", "php-pgsql", "php-pdo", "php-mbstring", "php-xmlrpc", "php-process" ]:
     ensure => present,
     notify => Service["apache::service"],
   }

....

}

Yet when I try to run puppet on the client node, I'm getting this result:

Could not retrieve fact='nr_java_found', resolution='<anonymous>': undefined method `start_with?' for nil:NilClass
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: Package[php] { notify => Service[apache::service] }, because Service[apache::service] doesn't seem to be in the catalog
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run


So just what in the heck am I doing wrong, if I may ask???

Thanks!!
Tim


--
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

jcbollinger

unread,
May 1, 2015, 8:50:41 AM5/1/15
to puppet...@googlegroups.com


On Thursday, April 30, 2015 at 10:38:29 PM UTC-5, bluethundr wrote:
Yet when I try to run puppet on the client node, I'm getting this result:

Could not retrieve fact='nr_java_found', resolution='<anonymous>': undefined method `start_with?' for nil:NilClass
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid relationship: Package[php] { notify => Service[apache::service] }, because Service[apache::service] doesn't seem to be in the catalog
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run


So just what in the heck am I doing wrong, if I may ask???


"apache::service" is the name of a class. Evidently it is not the name of a Service resource declared by that class, or by any other from which your catalog is built.  It would probably work to notify the class (and if so then that would be the best solution), but it's possible that you'll need to discover the Service's name (probably "httpd") and notify it directly.


John

Doug Byrne

unread,
May 1, 2015, 8:52:06 AM5/1/15
to puppet...@googlegroups.com
'apache::service' is the name of a Class. You can look inside that class to find the service resource you're trying to notify. It's probably Service['apache2'].

-Doug
Reply all
Reply to author
Forward
0 new messages