Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We're using Puppet to manage an OpenStack installation. OpenStack consists of a number of loosely connected parts, all communicating via AMQP. Several of the parts use a common configuration file (/etc/nova/nova.conf), so a typical service resource looks like this:

service { 'openstack-nova-network':
  ensure    => running,
  enable    => true,
  subscribe => File['/etc/nova/nova.conf'],
}

This all works great.

Now we're using Puppet to install a hotfix to some of the underlying Python code. When we replace one of the Python source files, we would like to restart the services that make use of it. In general, this is exactly the same set of services that are subscribed to /etc/nova/nova.conf.

I was hoping I could do this take advantage of the existing dependencies by notifying the file, like this...

file { '/path/to/some/file':
  source => 'puppet:///.../',
  notify => File['/etc/nova/nova.conf'],
}

...but this didn't appear to work. Other than putting in explicit notify entries for every service, is there a better way to do this?

UPDATE

You know, I'm beginning to suspect my question wasn't entirely clear. I'd like to apologize for the confusion and try to make my request a little more explicit:

I realize I can do this with a set of explicit dependencies, either as subscribe values on the services or notify values on the installed files. The problem is that this means maintaining an M*N matrix of dependencies. Introducing a new file means either:

  • Updating M service resources, or
  • Updating N file resources

This sort of repetitive copy-and-paste work is prone to errors, especially when multiple people are responsible for the configuration.

One option would be to maintain a central list of services:

$services = [ service1, service2, service ]

Because then I could do this:

file { '/usr/lib/python/glance/notifier/notify_qpid.py':
  notify => Service[$services],
}

But that's not going to work, because the list of services is different on different hosts. Possibly I can flip this around and maintain a list of "hotfix" files:

$hotfix_files = [
  '/usr/lib/python2.6/site-packages/glance/notifier/notify_qpid.py',
  '/root/puppet/modules/openstack/files/nova/impl_qpid.py',
]

And then update all the service definitions once:

service { 'openstack-nova-network':
  ensure    => running,
  enable    => true,
  subscribe => [
    File['/etc/nova/nova.conf'],
    File[$hotfix_files],
  ]
}

But this still requires manually maintaining the list of modified files.

What I really want to do is say, "notify all the services that are subscribed to /etc/nova/nova.conf".

share|improve this question
    
How are the hotfix files being deployed? With Puppet as File resources? As packages? Without Puppet? I assume you've thought of the hacky solution of making a whitespace change to nova.conf to trigger this? ;-) –  mgorven Aug 3 '12 at 6:50
    
As file resources... –  larsks Aug 3 '12 at 11:06

3 Answers 3

The main thing you are after, "notify all the services that are subscribed to /etc/nova/nova.conf", doesn't seem to be possible with file-resources. But, it works with exec-resources, with refreshonly-parameter. (Just tested similar configuration with Puppet 2.7.11). You must add a dummy exec-resource:

exec {'dummy-nova-refresh':
    command     => "/bin/true",
    refreshonly => true,
}

When the command is run, exec sends notification to all its subscribers. And refreshonly-parameter makes sure that command is run only on refresh.

Subscribe all services to this Exec:

service { 'openstack-nova-network':
    ensure    => running,
    enable    => true,
    subscribe => Exec['dummy-nova-refresh'],
}

And use notify from all file-resources. (Do this also for /etc/nova/nova.conf, or specify it in the subscribe list for each service):

file { '/path/to/some/file':
    source => 'puppet:///.../',
    notify => Exec['dummy-nova-refresh'],
}

And done. A change in any file triggers a refresh in all services subscribed to 'dummy-nova-refresh'.

share|improve this answer

I'm not really an expert on neither both technologies, but I think you have to subscribe the service you want to restart to the replaced file. Something like:

  configfile { "/etc/httpd/conf/httpd.conf":
    source => "/httpd/httpd.conf",
    mode => 644,
  }

  service { httpd:
    running => true,
    subscribe => file["/etc/httpd/conf/httpd.conf"]
  }

Not sure if this syntax is properly written but I hope you get the idea.

share|improve this answer
    
So I think maybe you didn't understand the question. The services are already subscribed to the configuration file...the question is whether it's possible to take advantage of this relationship when changing another file, or whether I need an explicit subscribe/notify for each service (for each file that is changed). –  larsks Aug 2 '12 at 17:02
    
Sorry my bad...I didn't. As far as I know you have to do it for each one of your services/files. –  tripledes Aug 2 '12 at 17:10
    
I just found some information about defining packages which might be of some help: puppetcookbook.com/posts/… –  tripledes Aug 2 '12 at 17:12
    
Thanks for the link! –  larsks Aug 2 '12 at 17:38
service { 'openstack-nova-network':
  ensure    => running,
  enable    => true,
  subscribe => [
               File['/etc/nova/nova.conf'],
               File['/path/to/some/file'],
               ],
}

That should work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.