Skip to content

Instantly share code, notes, and snippets.

@jordansissel
Created October 15, 2010 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordansissel/627327 to your computer and use it in GitHub Desktop.
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.
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
define placeholder($ready) {
# Nothing to do, it's a placeholder!
}
class foo {
@@placeholder {
"superserver":
ready => true;
}
}
# 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