Created
December 8, 2010 05:25
-
-
Save xdissent/732929 to your computer and use it in GitHub Desktop.
delete vagrant vm's chef client and node from chef server on destroy
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
class OnDestroyMiddleware | |
def initialize(app, env) | |
@app = app | |
end | |
def call(env) | |
`knife client show #{env["config"].chef.node_name}` | |
if $?.to_i == 0 | |
env.ui.info "Removing client #{env["config"].chef.node_name}" | |
`knife client delete #{env["config"].chef.node_name} -y` | |
end | |
`knife node show #{env["config"].chef.node_name}` | |
if $?.to_i == 0 | |
env.ui.info "Removing node #{env["config"].chef.node_name}" | |
`knife node delete #{env["config"].chef.node_name} -y` | |
end | |
@app.call(env) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment