百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

knife-spork

> 编程语言
开源

一个工作流插件,可帮助许多开发人员同时处理烹饪书和环境

333 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个工作流插件,可帮助许多开发人员同时处理烹饪书和环境

KnifeSpork

KnifeSpork is a workflow plugin for Chef::Knife which helps multiple developers work on the same Chef Server and repository without treading on each other's toes. This plugin was designed around the workflow we have here at Etsy, where several people are working on the Chef repository and Chef Server simultaneously. It contains several functions, documented below: Maintenance Status Warning

Knife-Spork is not being particularly actively maintained at this time as the primary author does not currently use it day-to-day. Pull requests and issues might therefore take a while to be actioned - please feel free to reach out if you run into something you consider an urgent blocker.

Installation

Gem Install

knife-spork is available on rubygems. Add the following to your Gemfile:

ruby
gem 'knife-spork'

or install the gem manually:

bash
gem install knife-spork

knife-spork is also included in the Chef Devlopment Kit.

Please note: As of version 1.6.0, knife-spork requires Ruby 2.1.1 or greater and Chef version 11.0.0 or greater. If you're still using sev_level: lint: false use_cookstyle: true

…

knife spork environment createcommand save a copy of the new environment to your Chef repository. This will default to saving environment files in the location specified by theenvironment_path``` directive. If this parameter is not specified, spork will default to using the first element of your cookbook_path, replacing the word "cookbooks" with "environments"

Role Path

The role_path allows you to specify the path to where you store your chef role json files. If this parameter is not specified, spork will default to using the first element of your cookbook_path, replacing the word "cookbooks" with "roles"

Role Safe Delete

The role_safe_delete flag will, when you use the spork ```knife spork role delete

…

bash knife spork info


#### Example

```text
$ knife spork info
Config Hash:
{"plugins"=>{"git"=>{"enabled"=>true}, "irccat"=>{"server"=>"irccat.mydomain.com", "port"=>12345, "gist"=>"usr/bin/gist", "channel"=>["#chef-announce"]}, "graphite"=>{"server"=>"graphite.mydomain.com", "port"=>2003}, "slack"=>{"api_token"=>"abc123", "channel"=>"random", "teamname"=>"myteam", "icon_url"=>"http://example.com/image.jpg"}, "eventinator"=>{"url"=>"http://eventinator.mydomain.com/events/oneshot"}}, "default_environments"=>["development", "production"], "version_change_threshold"=>2, "pplugins"=>{"foodcritic"=>{"fail_tags"=>["style,correctness,test"], "tags"=>["~portability"], "include_rules"=>["config/rules.rb"]}}}

Plugins:
KnifeSpork::Plugins::Campfire: disabled
KnifeSpork::Plugins::Eventinator: enabled
KnifeSpork::Plugins::Foodcritic: disabled
KnifeSpork::Plugins::Git: enabled
KnifeSpork::Plugins::Graphite: enabled
KnifeSpork::Plugins::HipChat: disabled
KnifeSpork::Plugins::Slack: enabled
KnifeSpork::Plugins::Irccat: enabled

Spork Check

This function is designed to help you avoid trampling on other people's cookbook versions, and to make sure that when you come to version your own work it's easy to see what version numbers have already been used and if the one you're using will overwrite anything.

Usage

bash
knife spork check COOKBOOK [--all]

By default, spork check only shows the 5 most recent remote cookbook versions. Add the --all option if you want to see everything.

Example (Checking an Unfrozen Cookbook with version clash)

$ knife spork check apache2
Checking versions for cookbook apache2...

Local Version:
  1.1.49

Remote Versions: (* indicates frozen)
 *2.0.2
 *2.0.1
  1.1.49
 *1.1.14
 *1.1.13

ERROR: The version 1.1.49 exists on the server and is not frozen. Uploading will overwrite!

Example (Checking a Frozen Cookbook with version clash)

$ knife spork check apache2
Checking versions for cookbook apache2...

Local Version:
  2.0.2

Remote Versions: (* indicates frozen)
 *2.0.2
 *2.0.1
  1.1.49
 *1.1.14
 *1.1.13

WARNING: Your local version (2.0.2) is frozen on the remote server. You'll need to bump before you can upload.

Example (No version clashes)

$ knife spork check apache2
Checking versions for cookbook apache2...

Local Version:
  2.0.3

Remote Versions: (* indicates frozen)
 *2.0.2
 *2.0.1
  1.1.49
 *1.1.14
 *1.1.13

Everything looks good!

Spork Bump

This function lets you easily version your cookbooks without having to manually edit the cookbook's metadata.rb file. You can either specify the version level you'd like to bump (major, minor, or patch), or you can manually specify a version number. This might be used if, for example, you want to jump several version numbers in one go and don't want to have to run knife bump once for each number. If no bump level is specified, a patch level bump will be performed.

Usage

bash
knife spork bump COOKBOOK [major | minor | patch | manual x.x.x]

Example (No patch level specified - defaulting to patch)

$ knife spork bump apache2
Successfully bumped apache2 to v2.0.4!

Example (Bumping patch level)

$ knife spork bump apache2 patch
Successfully bumped apache2 to v2.0.4!

Example (Manually setting version)

$ knife spork bump apache2 manual 1.0.13
Successfully bumped apache2 to v1.0.13!

Spork Upload

This function works mostly the same as normal knife cookbook upload COOKBOOK except that this automatically freezes cookbooks when you upload them.

Usage

bash
knife spork upload COOKBOOK

Example

$ knife spork upload apache2
Freezing apache2 at 1.0.13...
Successfully uploaded [email protected]!

…

bash
knife spork promote [ENVIRONMENT OR ENVIRONMENT GROUP NAME] COOKBOOK [--version, --remote]

Example (Using local cookbook version number)

$ knife spork promote my_environment apache2 --remote
Adding version constraint apache2 = 1.0.13
Saving changes to my_environment.json
Uploading my_environment to Chef Server
Promotion complete!

Example (Using manual version)

$ knife spork promote my_environment apache2 -v 2.0.2
Adding version constraint apache2 = 2.0.2
Saving changes to my_environment.json
Promotion complete. Don't forget to upload your changed my_environment to Chef Server

Spork Delete

This function works mostly the same as normal knife cookbook delete COOKBOOK including options to delete all versions and delete without interactive confirmation.

Usage

bash
knife spork delete COOKBOOK

Example

$ knife spork delete apache2 -a
WARNING: Deleting cookbook apache2...
Do you really want to delete all versions of apache2? (Y/N) Y
Deleted cookbook[apache2][2.0.2]
Successfully deleted cookbook apache2 ALL versions from the Chef server
Cookbooks deleted from Chef server: apache2: ALL versions

Spork Omni

Omni lets you combine one of the most common combinations of spork commands (bump, upload & promote or promote --remote) - into one handy shortcut.

As omni is designed for use only in those cases where you want to perform all three of bump, upload and promote at the same time it supports a limited subset of the command line options supported by the individual bump, upload and promote commands.

If you run omni with no extra options, it will default to performing a patch level bump, and promote locally to the environments listed in the default_environments variable in your spork configuration file.

Alternatively, you can specify any of the following options:

--cookbook-path PATH:PATH: A colon-separated path to look for cookbooks in

--include-dependencies: Also upload cookbook dependencies during the upload step

--bump-level [major|minor|patch]: Version level to bump the cookbook (defaults to patch)

--environment ENVIRONMENT: Environment to promote the cookbook to',

--remote: Make omni perform a promote --remote instead of a local promote',

Usage

bash
knife spork omni COOKBOOK [--bump-level, --cookbook-path, --include-dependencies, --environment, --remote]

Example (default options, default_environments set to development and production)

$ knife spork omni apache2
OMNI: Bumping apache2
Successfully bumped apache2 to v0.3.99!

OMNI: Uploading apache2
Freezing apache2 at 0.3.99...
Successfully uploaded [email protected]!

OMNI: Promoting apache2
Adding version constraint apache2 = 0.3.99
Saving changes to development.json
Promotion complete. Don't forget to upload your changed development.json to Chef Server
Adding version constraint apache2 = 0.3.99
Saving changes to production.json
Promotion complete. Don't forget to upload your changed production.json to Chef Server

Example (default options, default_environments set to development and production, promote --remote)

$ knife spork omni apache2 --remote
OMNI: Bumping apache2
Successfully bumped apache2 to v0.3.99!

OMNI: Uploading apache2
Freezing apache2 at 0.3.99...
Successfully uploaded [email protected]!

OMNI: Promoting apache2
Adding version constraint apache2 = 0.3.99
Saving changes to development.json
Uploading development.json to Chef Server
Promotion complete at 2013-08-08 11:43:12 +0100!
Adding version constraint apache2 = 0.3.99
Saving changes to production.json
Uploading production.json to Chef Server
Promotion complete at 2013-08-08 11:43:12 +0100!

Example (Specifying patch level and environment)

$ knife spork omni apache2 -l minor -e development
OMNI: Bumping apache2
Successfully bumped apache2 to v0.4.0!

OMNI: Uploading apache2
Freezing apache2 at 0.4.0...
Successfully uploaded [email protected]!

OMNI: Promoting apache2
Adding version constraint apache2 = 0.4.0
Saving changes to development.json
Promotion complete. Don't forget to upload your changed development.json to Chef Server

Spork Environment Check

Environment check provides the ability to validate a local chef environment file is locked to versions that actually exist on the chef server. Running this check prior to uploading your environment files is recommended as it can prevent your chef server from becoming unresponsive due to a version constraint that will never be valid.

If you run environment check with no options it will collect all invalid cookbook versions before reporting a failure.

Alternatively, you can specify any of the following options:

-f, --fatal: Quit on first invalid constraint located

Usage

bash
knife spork environment check ENVIRONMENT (options)

Example of a passing chef environment check with no options

$ knife spork environment check production

Checking constraints for environment: production
Environment production looks good

Example of multiple invalid cookbooks with no options

$ knife spork environment check production

Checking constraints for environment: production
ERROR: [email protected] does not exist on Chef Server! Upload the cookbook first by running:

	knife spork upload mysql

ERROR: [email protected] does not exist on Chef Server! Upload the cookbook first by running:

	knife spork upload rbenv

FATAL: Environment production has constraints that point to non existent cookbook versions.

Example of running with the --fatal flag with the same invalid cookbooks from previous example

$ knife spork environment check production

Checking constraints for environment: production
FATAL: [email protected] does not exist on Chef Server! Upload the cookbook first by running:

	knife spork upload mysql

Spork Node / Role / Databag Commands

Knife spork contains "wrappers" around several stock knife commands for changing nodes, roles, environments and databags. These commands work exactly as in the original knife, wi

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言