Last active
August 29, 2015 13:58
-
-
Save hlindberg/9975348 to your computer and use it in GitHub Desktop.
ducks in a row - puppet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define duck($name) { | |
notice "duck $name" | |
include c | |
} | |
class c { | |
notice 'in c' | |
duck { 'duck0': name => 'mc scrooge' } | |
} | |
class a { | |
notice 'in a' | |
duck {'duck1': name => 'donald' } | |
include b | |
duck {'duck2': name => 'daisy' } | |
} | |
class b { | |
notice 'in b' | |
duck {'duck3': name => 'huey' } | |
duck {'duck4': name => 'dewey' } | |
duck {'duck5': name => 'louie' } | |
} | |
include a |
Answer:
Notice: Scope(Class[A]): in a Notice: Scope(Class[B]): in b Notice: Scope(Duck[duck1]): duck donald Notice: Scope(Class[C]): in c Notice: Scope(Duck[duck3]): duck huey Notice: Scope(Duck[duck4]): duck dewey Notice: Scope(Duck[duck5]): duck louie Notice: Scope(Duck[duck2]): duck daisy Notice: Scope(Duck[duck0]): duck mc scrooge
why is mc scrooge at the end?
mc scrooge
is at the end because it is pushed onto the end of the FIFO queue to process defines. Because a
and b
are classes the creation of their duck
resources is evaluated as soon as it evaluates the include
statements inside the classes. However, mc scrooge
isn't enqueued until the first duck is evaluated, which is after the a
and b
classes. This means that it goes to the end of the queue and so will show up last.
"the creation of their duck resources is evaluated as soon as it evaluates the include statements". To clarify, it is the creation of the resources that is done immediately, but not the evaluation of their bodies.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does this print out?