Ask Your Question
1

puppet subscribe wildcards

asked 2014-11-18 13:07:28 -0500

updated 2014-11-18 16:01:09 -0500

ramindk gravatar image

Hi,

I want to do the following:

service { 'nagios':
  ensure    => running,
  subscribe => File[ "/etc/nagios/nagios.cfg", "/etc/nagios/hosts/*.cfg", ],
}

Is there a better way or what am I missing?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-11-18 16:00:05 -0500

ramindk gravatar image

updated 2014-11-18 16:01:41 -0500

There is not a way to use a wild card. However some of the options below may work for you.

It's almost always better to notify in a many to one relationship rather than trying to make sure one thing is subscribing to all. Also masks your commit cleaner because adding a new file is a single stanza rather than needing to touch two.

file { '/etc/nagios/nagios.cfg':
  content => 'blah',
  notify  => Service['nagios'],
}

If you break your classes up, you can deal with ordering at the class level.

class nagios { 
  include nagios::install, nagios::config, nagios::service

  Class['nagios::install'] -> Class['nagios::config'] ~> Class['nagios::service']
}

You could also tag resources

file { '/etc/nagios/nagios.cfg':
  content => 'blah',
  tag     => 'nagios',
}

File <| tag == 'nagios'|> ~> Service['nagios']
edit flag offensive delete link more
0

answered 2014-11-18 17:00:49 -0500

Thanks for the answers!

I did end up putting a

notify  => Service['nagios'],

on each file under /etc/nagios, which is not very efficient, but it is solid, and works.

But I do like the tag feature so I will start using that instead, it looks a lot more efficient.

Thanks very much for the tips!

Tim

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-18 13:07:28 -0500

Seen: 378 times

Last updated: Nov 18 '14