[Puppet Users] Unexpected dependency cycle

75 views
Skip to first unread message

Ben Beuchler

unread,
May 24, 2010, 8:03:25 PM5/24/10
to puppet...@googlegroups.com
The class below is designed to ensure that a fifo exists that will be
written to by Apache and read from by syslog-ng. I've attached the
relevant chunk of the dependency graph. It's obvious to me why
Exec[access_log_pipe] is a parent node of
File[/var/spool/apache2/access_log_pipe], but I don't understand why
there is any relationship at all between
File[/var/spool/apache2/access_log_pipe] and Exec[cleanup_alp]. I
assume there's an implied relationship created somehow, but I don't
see where. How can I restructure this relationship to avoid the
cycle?

Thanks!

-Ben

class syslog-ng::weblogger inherits syslog-ng {
$alp = "/var/spool/apache2/access_log_pipe"

file { "/var/spool/apache2":
ensure => directory,
owner => www-data,
group => www-data
}

File["/etc/syslog-ng/syslog-ng.conf"] {
require => File[ "$alp" ]
}

## TODO: Write a FIFO resource.

# If apache started first and created $alp as a normal file, delete
# it.
exec { "cleanup_alp":
command => "/bin/rm ${alp}",
unless => "/usr/bin/test -p ${alp}",
}

# If the FIFO doesn't exist, create it.
exec { "access_log_pipe":
command => "/usr/bin/mkfifo ${alp}",
unless => "/usr/bin/test -p ${alp}",
require => Exec["cleanup_alp"],
}

# Ensure permissions are correct on the pipe.
file { "$alp":
ensure => present,
owner => www-data,
group => www-data,
mode => 0770,
require => Exec["access_log_pipe"]
}
}

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Screen shot 2010-05-24 at 6.41.28 PM.png

Patrick

unread,
May 24, 2010, 8:32:31 PM5/24/10
to puppet...@googlegroups.com
I can't tell you why it's happening, but you can probably fix it by replacing the file resource with an exec that does a chmod and chown.

Dan Bode

unread,
May 25, 2010, 8:48:55 AM5/25/10
to puppet...@googlegroups.com
Hi Ben,

On Mon, May 24, 2010 at 5:03 PM, Ben Beuchler <ins...@gmail.com> wrote:
The class below is designed to ensure that a fifo exists that will be
written to by Apache and read from by syslog-ng.  I've attached the
relevant chunk of the dependency graph.   It's obvious to me why
Exec[access_log_pipe] is a parent node of
File[/var/spool/apache2/access_log_pipe], but I don't understand why
there is any relationship at all between
File[/var/spool/apache2/access_log_pipe] and Exec[cleanup_alp].  I
assume there's an implied relationship created somehow,

Can you open a ticket? It looks like it might be a bug.

I had a peek at the code and it looks like onlyif/unless autorequire any strings that have a slash in them as files.

reqs += line.scan(%r{(#{File::SEPARATOR}\S+)})

I ran some tests, and saw a slightly different behavior. I could recreate with the following code:

   $alp = "/tmp/one"
   exec { "test1":

       command => "/bin/rm ${alp}",
       unless  => "/bin/test ${alp}",
   }
   exec { "test2":
       command => "/bin/touch  ${alp}",
       unless  => "/bin/test ${alp}",
       require => Exec["test1"],

   }
   file { "$alp":
       ensure => present,
       mode   => 0770,
       require => Exec["test2"]
   }

but not with:

   $alp = "/tmp/one"
   exec { "test1":

       command => "/bin/rm ${alp}",
       unless  => "/bin/test ${alp}",

   }
   file { "$alp":
       ensure => present,
       mode   => 0770,
       require => Exec["test1"]
   }
 
 
Reply all
Reply to author
Forward
0 new messages