An open API service indexing awesome lists of open source software.

https://github.com/linuxthor/knife-gadgets

Add hooks to knife to run custom scripts at key points
https://github.com/linuxthor/knife-gadgets

Last synced: 5 months ago
JSON representation

Add hooks to knife to run custom scripts at key points

Awesome Lists containing this project

README

          

# knife-gadgets
A knife plugin that adds hooks to knife to run external scripts at key points and potentially abort the action being taken.

Install by copying to .chef/plugins/knife/

Currently there are two hooks in the 'cookbook upload' command:

1. Before syntax checking (useful for extra checking/linting of cookbooks)
2. After syntax checking has passed but before upload takes place (a good time to commit to SCM)

When the hook code runs it checks if the configuration options 'prevalidate_hook' and 'postvalidate_hook' are set (e.g in knife.rb) and runs the scripts they point to.

Example knife.rb settings:

```
prevalidate_hook "/home/user/Chef/prevalidate_cookbook.sh"
postvalidate_hook "/home/user/Chef/postvalidate_cookbook.sh"
```

The following environment variables are populated when calling the external helper:

```
$CURRENT_COOKBOOK #name of the current cookbook
$COOKBOOK_PATH #filesystem path to cookbooks
$NODE_NAME #name of client

```
If a script returns a non-zero exit code the 'cookbook upload' operation is aborted.

It is planned to add additional hooks over time.