Skip to content

Instantly share code, notes, and snippets.

@reidmv
Created November 11, 2014 00:11
Show Gist options
  • Save reidmv/4d12bb7602a0e78af8f9 to your computer and use it in GitHub Desktop.
Save reidmv/4d12bb7602a0e78af8f9 to your computer and use it in GitHub Desktop.
autobefore in Puppet
# This type needs to implement an "autobefore" kind of behavior. Currently
# the Puppet type system only supports autorequire, so we achieve autobefore
# by hijacking autorequire.
def autorequire(rel_catalog = nil)
reqs = super
[ @parameters[:prior_to].value,
@parameters[:resource].value
].flatten.each do |rel|
reqs << Puppet::Relationship::new(self, catalog.resource(rel.to_s))
end
reqs
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment