i require a defined type which contains a file resource, but the file resource does not retain the relatioship

51 views
Skip to first unread message

David Portabella

unread,
Mar 19, 2014, 8:54:27 AM3/19/14
to puppet...@googlegroups.com
I have this test.pp example on puppet 3.4.3 on OSX 10.9:

c2 {'test': }
-> 
c3 {'test': }

define c1 {
  notice "+++"
  file {'/tmp/c1.txt': ensure => present }
}

define c2 {
  c1 {$name: }
  notice "+++"
  file {'/tmp/c2.txt': ensure => present }
}

define c3 {
  notice "+++"
  file {'/tmp/c3.txt': ensure => present }
}

running:

$ puppet apply --graph test.pp 

produces this graph /Users/david/.puppet/var/state/graphs/relationships.dot,

which shows that /tmp/c3.txt does not require /tmp/c2.txt.

why?

digraph Relationships {

    label = "Relationships"
    "Stage[main]" [
        fontsize = 8,
        label = "Stage[main]"
    ]

    "Class[Settings]" [
        fontsize = 8,
        label = "Class[Settings]"
    ]

    "Class[Main]" [
        fontsize = 8,
        label = "Class[Main]"
    ]

    "C2[test]" [
        fontsize = 8,
        label = "C2[test]"
    ]

    "C3[test]" [
        fontsize = 8,
        label = "C3[test]"
    ]

    "C1[test]" [
        fontsize = 8,
        label = "C1[test]"
    ]

    "File[/tmp/c2.txt]" [
        fontsize = 8,
        label = "File[/tmp/c2.txt]"
    ]

    "File[/tmp/c3.txt]" [
        fontsize = 8,
        label = "File[/tmp/c3.txt]"
    ]

    "File[/tmp/c1.txt]" [
        fontsize = 8,
        label = "File[/tmp/c1.txt]"
    ]

    "Schedule[puppet]" [
        fontsize = 8,
        label = "Schedule[puppet]"
    ]

    "Schedule[hourly]" [
        fontsize = 8,
        label = "Schedule[hourly]"
    ]

    "Schedule[daily]" [
        fontsize = 8,
        label = "Schedule[daily]"
    ]

    "Schedule[weekly]" [
        fontsize = 8,
        label = "Schedule[weekly]"
    ]

    "Schedule[monthly]" [
        fontsize = 8,
        label = "Schedule[monthly]"
    ]

    "Schedule[never]" [
        fontsize = 8,
        label = "Schedule[never]"
    ]

    "Filebucket[puppet]" [
        fontsize = 8,
        label = "Filebucket[puppet]"
    ]

    "C2[test]" -> "C3[test]" [
        fontsize = 8
    ]

}

jcbollinger

unread,
Mar 19, 2014, 4:51:08 PM3/19/14
to puppet...@googlegroups.com


On Wednesday, March 19, 2014 7:54:27 AM UTC-5, David Portabella wrote:
I have this test.pp example on puppet 3.4.3 on OSX 10.9:

c2 {'test': }
-> 
c3 {'test': }

define c1 {
  notice "+++"
  file {'/tmp/c1.txt': ensure => present }
}

define c2 {
  c1 {$name: }
  notice "+++"
  file {'/tmp/c2.txt': ensure => present }
}

define c3 {
  notice "+++"
  file {'/tmp/c3.txt': ensure => present }
}

running:

$ puppet apply --graph test.pp 

produces this graph /Users/david/.puppet/var/state/graphs/relationships.dot,

which shows that /tmp/c3.txt does not require /tmp/c2.txt.

why?



I don't know, and your graph did not come across.  However, it may simply be a case of Puppet optimizing.  Two unrelated File resources cannot have a bona fide ordering relationship between them, because syncing one in no way affects syncing the other.

Still, I find it surprising.  Is there at least a chain of relationships that will cause File['/tmp/c2.txt'] to be applied before File['/tmp/c3.txt']?  Are you sure the catalog you analyzed corresponds to the version of your manifest set that contains the chain operator you depict?


John

David Portabella

unread,
Mar 27, 2014, 6:11:02 AM3/27/14
to puppet...@googlegroups.com
I've open a bug ticket:
puppet --graph misses some dependencies


d1 {'test': }
-> 
d2 {'test': }

define d1 {
  exec { exec1: command => '/bin/echo exec1; exit 1' }
}

define d2 {
  exec { exec2: command => '/bin/echo exec2; exit 1' }
}

---
$ puppet apply --graph test.pp 

the graph does not show any dependency between exec1 and exec2.

However the dependency does exists, as puppet does nor execute exec2 because of "failed dependencies":

$ puppet apply --graph dd.pp 
Notice: Compiled catalog for mac4c.local in environment production in 0.08 seconds
Notice: /Stage[main]//D1[test]/Exec[exec1]/returns: exec1
Error: /bin/echo exec1; exit 1 returned 1 instead of one of [0]
Error: /Stage[main]//D1[test]/Exec[exec1]/returns: change from notrun to 0 failed: /bin/echo exec1; exit 1 returned 1 instead of one of [0]
Notice: /Stage[main]//D2[test]/Exec[exec2]: Dependency Exec[exec1] has failures: true
Warning: /Stage[main]//D2[test]/Exec[exec2]: Skipping because of failed dependencies
Notice: Finished catalog run in 0.11 seconds


So, it seems that there is a bug in puppet --graph.

David Portabella

unread,
Mar 27, 2014, 6:22:13 AM3/27/14
to puppet...@googlegroups.com
d2 {'test': }
->
d3 {'test': }


define d1 {
  exec { exec1: command => '/bin/echo exec1; exit 1' }
}

define d2 {
  d1 {$name: }
  ->

  exec { exec2: command => '/bin/echo exec2; exit 1' }
}

define d3 {
  exec { exec3: command => '/bin/echo exec3; exit 1' }
}


and this also works as expected, even if puppet --graph does not show it.

$ puppet apply --graph cc.pp
Notice: Compiled catalog for mac4c.local in environment production in 0.08 seconds
Notice: /Stage[main]//D2[test]/D1[test]/Exec[exec1]/returns: exec1
Error: /bin/echo exec1; exit 1 returned 1 instead of one of [0]
Error: /Stage[main]//D2[test]/D1[test]/Exec[exec1]/returns: change from notrun to 0 failed: /bin/echo exec1; exit 1 returned 1 instead of one of [0]
Notice: /Stage[main]//D2[test]/Exec[exec2]: Dependency Exec[exec1] has failures: true
Warning: /Stage[main]//D2[test]/Exec[exec2]: Skipping because of failed dependencies
Notice: /Stage[main]//D3[test]/Exec[exec3]: Dependency Exec[exec1] has failures: true
Warning: /Stage[main]//D3[test]/Exec[exec3]: Skipping because of failed dependencies
Notice: Finished catalog run in 0.14 seconds

$ open -a GraphViz /Users/david/.puppet/var/state/graphs/relationships.dot 

no relation between exec1, exec2 and/or exec3.

David Portabella

unread,
Mar 27, 2014, 7:05:54 AM3/27/14
to puppet...@googlegroups.com
simpler example, showing the transivity in resource dependencies.
(as opposed to no transivity in class dependencies by default)

d3 {'test': }

define d1 {
  exec { exec1: command => '/bin/echo exec1; exit 1' }
}

define d2 {
  d1 {$name: }
}

define d3 {
  d2 {$name: }
  ->
  exec { exec3: command => '/bin/echo exec3; exit 1' }
}

$ puppet apply test.pp
Notice: /Stage[main]//D3[test]/D2[test]/D1[test]/Exec[exec1]/returns: exec1
Error: /bin/echo exec1; exit 1 returned 1 instead of one of [0]
Error: /Stage[main]//D3[test]/D2[test]/D1[test]/Exec[exec1]/returns: change from notrun to 0 failed: /bin/echo exec1; exit 1 returned 1 instead of one of [0]
Reply all
Reply to author
Forward
0 new messages