Ask Your Question
0

Can you notify an 'Exec' command defined in another file in the same module class?

asked 2016-04-01 07:11:37 -0500

Guy gravatar image

Hello,

I have a module class that's broken up into different files like so:

[mod]
init.pp
[mod/server]
install.pp
config_server.pp

In the install.pp I have the install sub-class that installs the yum package. Then it has a notify statement to call the sub-class in the config_server.pp; but it never gets triggered because Puppet can't find the Exec statement in the other file:

[install.pp]
class mod::server::install inherits mod {
  package { 'mypkg':
    ensure              => $package_ensure_server,
    name                => $package_name_server,
    notify              => Exec['mypkg-config'],
  }

[config_server.pp]
class mod::server::config_server inherits mod {
  exec { 'mypkg-config':
    command     => "mypkg-config ...",
    timeout     => 1800,
    path        => '/usr/sbin/:/usr/local/sbin/:/usr/bin/:/usr/local/bin/:/bin/',
  }
}

When I run puppet I get the error:

Error: Failed to apply catalog: Could not find dependent Exec[mypkg-config] for Package[mypkg] at /etc/puppet/environments/test/modules/mod/manifests/server/install.pp:6

I'm guessing my issue is with inheritance but I've tried a few things and nothing seems to work. Any ideas? Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2016-04-03 04:45:01 -0500

Why do you need inheritance at all? How is the classification done?

Normally you mention all subclasses in the init.pp. In your case:

init.pp

class mod {
 include mod::server::install
 include mod::server::config_server
 Class['mod::server::install'] ~> Class['mod::server::config_server']
}

mod/server/config_server.pp

class mod::server::config_server {
  exec { ...:
    command => ...,
    refreshonly => true,
   ...
  }
}
edit flag offensive delete link more

Comments

This is exactly what I was missing. I didn't have the second include statement for config_server in init.pp or the refreshonly in the config_server implementation. Thank you!

Guy gravatar imageGuy ( 2016-04-04 06:40:20 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-04-01 07:11:37 -0500

Seen: 366 times

Last updated: Apr 03 '16