You are not logged in.

#1 2012-11-30 18:17:23

From: Seattle
Registered: 2006-05-09
Posts: 1,326

Puppet:making a refreshonly exec run before something that notified it

With Puppet, I need to shut down httpd before something is backed up, like so:

  exec { 'Stop Apache httpd':
    command     => '/sbin/service httpd stop',
    onlyif      => '/sbin/service httpd status',
    refreshonly => true,
    before      => Exec['Create backup']

  exec { 'Create backup':
    command => '/bin/mv /opt/application /opt/application.git-backup',
    onlyif  => '/usr/bin/test -d /opt/application/.git',
    notify  => Exec['Stop Apache httpd']

However, this code produces this on the agent:

# puppet agent -t
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Caching catalog for server-x
Info: Applying configuration version '1354087433'
Error: Could not apply complete catalog: Found 1 dependency cycle:
(Exec[Create backup] => Exec[Stop Apache httpd] => Exec[Create backup])
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz
Finished catalog run in 0.84 seconds

How can I do this?  Brownie points if you can figure out a way to replace that Exec['Stop Apache httpd'] with a "service". smile

Last edited by synthead (2012-11-30 18:21:49)

Touch my kernel


Board footer

Powered by FluxBB