Created
October 15, 2010 00:06
-
-
Save jordansissel/627327 to your computer and use it in GitHub Desktop.
more detailed hack attempt at making only part of the puppet graph fail when an exported resource doesn't exist yet. Doesn't work since (thankfully) puppet doesn't let oyu override local resources with exported ones.
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 placeholder($ready) { | |
# Nothing to do, it's a placeholder! | |
} | |
class bar { | |
/* Should override the above */ | |
$placeholder = "superserver" | |
placeholder { | |
"$placeholder": | |
ready => false; | |
} | |
Placeholder <<| title == "$placeholder" |>> | |
Placeholder <| title == "$placeholder" and ready == false |> { | |
require +> Exec["failure, $placeholder is not ready"] | |
} | |
# Easy way to force an entire subgraph to fail. require this thing. | |
# Otherwise, nothing requires it but it always still fails... | |
# tricky... | |
exec { | |
"failure, $placeholder is not ready": | |
command => "/bin/false"; | |
} | |
file { | |
"/tmp/y": | |
content => "Importantserver is ok!\n", | |
require => Placeholder[$placeholder]; | |
} | |
} | |
include bar |
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 placeholder($ready) { | |
# Nothing to do, it's a placeholder! | |
} | |
class foo { | |
@@placeholder { | |
"superserver": | |
ready => true; | |
} | |
} |
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
# This works as expected, because the required placeholder 'superserver' has a ready | |
# value of 'false', so anything requiring it will fail | |
frontend1(~) % puppet apply --storeconfigs --config ./puppet.conf pull.pp | |
err: /Stage[main]/Bar/Exec[failure, superserver is not ready]/returns: change from notrun to 0 failed: /bin/false returned 1 instead of one of [0] at /home/jordan/pull.pp:24 | |
notice: /Whit[superserver]: Dependency Exec[failure, superserver is not ready] has failures: true | |
warning: /Whit[superserver]: Skipping because of failed dependencies | |
notice: /Stage[main]/Bar/File[/tmp/y]: Dependency Exec[failure, superserver is not ready] has failures: true | |
warning: /Stage[main]/Bar/File[/tmp/y]: Skipping because of failed dependencies | |
# Push readiness | |
ops(~/pp) % puppet apply --storeconfigs --config ./puppet.conf push.pp | |
# Try again, and it almost works. This shows that the logic from the pull.pp manifest is working, | |
# but there is policy in puppet (for good reason!) that prevents exported | |
# resources from overriding local ones. | |
frontend1(~) % puppet apply --storeconfigs --config ./puppet.conf pull.pp | |
Exported resource Placeholder[superserver] cannot override local resource on node frontend1.oktoberfest.loggly.net |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment