GithubHelp home page GithubHelp logo

knife-spork's Introduction

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:

Build Status Gem Version

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:

gem 'knife-spork'

or install the gem manually:

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 < Ruby 2.0 or Chef 11, please continue to use knife-spork 1.5.x Spork Configuration

Out of the box, knife spork will work with no configuration. However, you can optionally enable several features to enhance its functionality.

KnifeSpork will look for a configuration file in the following locations, in ascending order of precedence:

  • config/spork-config.yml
  • /etc/spork-config.yml
  • ~/.chef/spork-config.yml
  • .chef/spork-config.yml

Anything set in the configuration file in your home directory for example, will override options set in your Chef repository or /etc.

Below is a sample config file with all supported options and all shipped plugins enabled below, followed by an explanation of each section.

default_environments:
  - development
  - production
environment_groups:
  qa_group:
    - quality_assurance
    - staging
  test_group:
    - user_testing
    - acceptance_testing
version_change_threshold: 2
preserve_constraint_operators: true
environment_path: "/home/me/environments"
save_environment_locally_on_create: false
role_path: "/home/me/roles"
custom_plugin_path: "/home/me/spork-plugins"
always_promote_remote: true
skip_berkshelf: false
role_match_file_name: true
role_safe_delete: true
stdout_diffs
json_options:
  indent: "    "
plugins:
  campfire:
    account: myaccount
    token: a1b2c3d4...
  foodcritic:
    tags: ['any']
  hipchat:
    api_token: ABC123
    rooms:
      - General
      - Web Operations
    notify: true
    color: yellow
  jabber:
    username: YOURUSER
    password: YOURPASSWORD
    nickname: Chef Bot
    server_name: your.jabberserver.com
    server_port: 5222
    rooms:
      - [email protected]/spork
      - [email protected]/spork
  git:
    enabled: true
    auto_push: true
    branch: some_branch
  irccat:
    server: irccat.mydomain.com
    port: 12345
    gist: "/usr/bin/gist"
    channel: ["chef-annoucements"]
  graphite:
    server: graphite.mydomain.com
    port: 2003
  influxdb:
    database: deployments
    username: deploy
    password: deploy
    series: deployments
    host: influx.example.com
    port: 8086
  eventinator:
    url: http://eventinator.mydomain.com/events/oneshot
  slack:
    webhook_url: https://hooks.slack.com/services/ABCD/efgh
    channel: "#sysops"
    username: knife
    icon_url: http://example.com/image.jpg
  rubocop:
    epic_fail: true
    show_name: false
    autocorrect: false
    out_file: <file>
    sev_level: <C|W|E>
    lint: false
    use_cookstyle: true

Default Environments

The default_environments directive allows you to specify a default list of environments you want to promote changes to. If this option is configured and you omit the environment parameter when promoting KnifeSpork will promote to all environments in this list.

Environment Groups

The environment_groups directive allows you to specify a list of environments referenced by group names that you want to promote changes to.

Version Change Threshold

The version_change_threshold directive allows you to customise the threshold used by a safety check in spork promote which will prompt for confirmation if you're promoting a cookbook by more than version_change_threshold versions. This defaults to 2 if not set, ie promoting a cookbook from v1.0.1 to v 1.0.2 will not trip this check, wheras promoting from v1.0.1 to v1.0.3 will.

Preserve Constraint Operators

The preserve_constraint_operators directive causes spork promote to preserve existing version constraint operators in your environment files, only updating the version number. This directive is disabled by default, which causes spork to always use the = constraint.

Always Promote Remote

The always_promote_remote directive allows you to tell spork promote to always act as if the --remote option had been specified. This will also have the same effect on spork omni. This option should only be used if you're sure you want all changes to be uploaded to the server as soon as you run promote.

Skip Berkshelf

The skip_berkshelf directive is a temporary flag added in #138 to allow Berkshelf functionality to be optionally bypassed until Berkshelf 3 support has been added to knife-spork per #85. It simply removed the :Berkshelf constant from the namespace used by knife-spork.

JSON Options

The json_options directive allows you to tell spork to pass options to pretty_generate to control the format of the resulting json

Environment Path

The environment_path directive allows you to specify the path to where you store your chef environment 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 "environments"

Save Environment on Create

The save_environment_on_create directive allows you to have the knife spork environment create command save a copy of the new environment to your Chef repository. This will default to saving environment files in the location specified by the environment_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 command, check to see if any nodes currently have that role in their runlist and exit with an error message if any are found.

Role Match File Name

The role_match_file_name flag allows you to check whether the file name that is used to upload a role matches the role name as well. If the parameter is specified, or flag --match-filename is set, spork will not let you upload a role from a file unless the name matches the rolename.

Stdout Diffs

The stdout_diffs flag will cause any diffs generated by knife-spork (for example on events such as data bag uploads, role edits etc) to be displayed on stdout in addition to any notifications generated by plugins.

Custom Plugin Path

The custom_plugin_path allows you to specify an additional directory from which to load knife-spork plugins. If this parameter is not specified or the path set does not exist, only the default plugins shipped with knife-spork will be loaded (if enabled in config)

Plugins

Knife spork supports plugins to allow users to hook it into existing systems such as source control, monitoring and chat systems. Plugins are enabled / disabled by adding / removing their config block from the plugin section of the config file. Any of the default plugins shown above can be disabled by removing their section.

For more information on how to develop plugins for spork, please read the plugins/README.md file.

Spork Info

This function is designed to help you see which plugins you currently have loaded, and the current config Hash which knife spork is using.

Usage

knife spork info

Example

$ 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

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

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

knife spork upload COOKBOOK

Example

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

Spork Promote

This function lets you easily set a version constraint in an environment or group of environments for a particular cookbook. By default it will set the version constraint to whatever the local version of the specified cookbook is. Optionally, you can include a --version option which will set the version constraint for the specified cookbook to whatever version number you provide. You might want to use this if, for example, you pushed a version constraint for a cookbook version you don't want your nodes to use anymore, so you want to "roll back" the environment to a previous version. You can also specify the --remote option if you'd like to automatically upload your changed local environment file to the server. To promote to multiple environments, simply pass a list of them delimited with a comma.

If you don't specify an environment or environment group, the default_environments config directive will be used if set.

Usage

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

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

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

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, with the addition of being wrapped in Spork's plugin API. This means that for example, when you upload a role using spork you will see an IRC message containing details, and a gist of the role change.

The following data bag commands are provided in knife-spork:

knife spork data bag create
knife spork data bag delete
knife spork data bag edit
knife spork data bag from file

The following node commands are provided in knife-spork:

knife spork node create
knife spork node delete
knife spork node edit
knife spork node from file
knife spork node run_list add
knife spork node run_list remove
knife spork node run_list set

The following role commands are provided in knife-spork:

knife spork role create
knife spork role delete
knife spork role edit
knife spork role from file

The following environment commands are provided in knife-spork:

knife spork environment create
knife spork environment delete
knife spork environment edit
knife spork environment from file

Troubleshooting

If you get an error when running knife spork <command> and the message shown when running with the -VV flag contains:

undefined method `gsub' for #<Pathname:0x00000002d3a6b0> (NoMethodError)

...then you are probably using Librarian::Chef.install_path() in your knife.rb file.

To fix this you need to call .to_s on the install path, i.e. ``Librarian::Chef.install_path().to_s`.

knife-spork's People

Contributors

chazzly avatar ctrlok avatar dwradcliffe avatar gmcmillan avatar gregkare avatar grobie avatar ickymettle avatar jaym avatar jblaine avatar jeunito avatar jonlives avatar jordane avatar jperry avatar juliandunn avatar kdaniels avatar mrtazz avatar nickmarden avatar nishansubedi avatar oker1 avatar poliva83 avatar pschultz avatar rso avatar russss avatar sethvargo avatar shoekstra avatar tas50 avatar timurb avatar version2beta avatar vic3lord avatar zen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knife-spork's Issues

Minor typo in Readme example spork-config.yml

Just a heads up; minor typo in the sample spork-config.yml:

This:

hipchat:
api_token: ABC123
rooms:

Should be:

hip_chat:
api_token: ABC123
rooms:

Without the underscore, the hipchat plugin does not register as enabled.

Running commands in a subdir of repo root sometimes gives errors

If your only spork-config.yml is in the config dir of your chef repo, running spork commands outside of the repo root will give you this error:

/usr/lib64/ruby/gems/1.9.1/gems/knife-spork-1.0.0/lib/knife-spork/plugins/plugin.rb:40:in config': undefined methodgit' for nil:NilClass (NoMethodError)

That should be handled gracefully.

knife-spork 1.0.15 returns ERROR: Errno::ENOENT: No such file or directory -

I just updated from spork 1.0.14 to 1.0.15 and now am getting this:

sm-nyc-jdunn:chef-cookbooks$ knife spork check roles
Checking versions for cookbook roles...

Local Version:
0.2.8

Remote Versions: (* indicates frozen)
0.3.0
*0.2.7
*0.2.6
*0.2.5
*0.2.4

Everything looks good!
Running foodcritic against [email protected]...
ERROR: Errno::ENOENT: No such file or directory -

This doesn't happen under knife-spork 1.0.14.

If I run with -VV, it looks like the error is in the call to foodcritic:

/Users/jdunn/.rvm/gems/ruby-1.9.3-p327/gems/foodcritic-1.7.0/lib/foodcritic/dsl.rb:74:in read': No such file or directory - (Errno::ENOENT) from /Users/jdunn/.rvm/gems/ruby-1.9.3-p327/gems/foodcritic-1.7.0/lib/foodcritic/dsl.rb:74:inblock in load'

If I insert a "pp path" before line 73 of dsl.rb, I get:

Running foodcritic against [email protected]...
"/Users/jdunn/.rvm/gems/ruby-1.9.3-p327/gems/foodcritic-1.7.0/lib/foodcritic/rules.rb"
""
/Users/jdunn/.rvm/gems/ruby-1.9.3-p327/gems/foodcritic-1.7.0/lib/foodcritic/dsl.rb:74:in `read': No such file or directory - (Errno::ENOENT)

which looks to me like the new Spork is passing an extra, empty, rule list to foodcritic.

Multiple Cookbook paths not supported

Is there a particular reason that you aren't supporting multiple cookbook paths? Our team uses two cookbooks paths to separate vanilla cookbooks downloaded from Chef (ones we don't touch very often) and cookbooks that are edited often.

Promote all cookbooks blows up

Hi there,

Today we were trying to use the "promote all cookbooks" feature that we found in the code (lib/chef/knife/spork-promote.rb:56) and it looks to be broken. How to reproduce:

Code snippet:

#First load so plugins etc know what to work with
@environments, @cookbook = load_environments_and_cookbook

run_plugins(:before_promote)

#Reload cookbook and env in case a VCS plugin found updates
@environments, @cookbook = load_environments_and_cookbook

check_cookbook_uploaded(@cookbook)

@environments.each do |e|
  environment = load_environment(e)

  if @cookbook == 'all'
    ui.msg "Promoting ALL cookbooks to environment #{environment}"
    promote(environment, all_cookbooks)
  else
    promote(environment, @cookbook)
  end

So:

$ be knife spork promote devops all
ERROR: Chef::Exceptions::CookbookNotFound: Could not find cookbook 'all' in any of the sources!

The feature is not documented in any case, but we thought it was worth opening the issue. We believe that the massive refactoring in commit a75b01c may have something to do. Plugins runner was introduced (run_plugins(:before_promote)) and it does not support passing "all" as the name of the cookbook(s), blowing up on lib/knife-spork/runner.rb:120.

raise ::Chef::Exceptions::CookbookNotFound, "Could not find cookbook '#{cookbook_name}' in any of the sources!"

We are not sure what the best approach to fixing the issue is. We'll be happy to help if you guys give us a direction or something.

Cheers.

ActiveSupport's Hash#diff is deprecated

Running knife spork promote ENVIRONMENT COOKBOOK --remote causes a deprecation warning to be thrown:

https://github.com/rails/rails/blob/c0c87922baf47eed64a53d3afceba978bb175da9/activesupport/lib/active_support/core_ext/hash/diff.rb#L9

This is caused by:

# lib/knife-spork/runner.rb#152-156
def environment_diff(local_environment, remote_environment)
  local_environment_versions = local_environment.to_hash['cookbook_versions']
  remote_environment_versions = remote_environment.to_hash['cookbook_versions']
  remote_environment_versions.diff(local_environment_versions)
end

Double promotion does nothing but still alerts

Should it ?

KnifeSpork
4:47 PM
mdsol: atrullmdsol promoted the following cookbooks:   [email protected] to candidate
KnifeSpork
4:48 PM
mdsol: atrullmdsol promoted the following cookbooks:   [email protected] to candidate

It should probably error instead of alert and say this is already promoted to the live environment in the case of --remote.

Much like a frozen-cookbook error.

Alex

`view': undefined method `name' for #<Hash:0x00000002ca6898> (NoMethodError)

[marius@oc7758512065 chef-repo]$ knife node edit training06.novalocal -VV -e vi
DEBUG: Using configuration from /home/marius/chef-repo/.chef/knife.rb
DEBUG: Signing the request as mariuscc
DEBUG: Sending HTTP Request via GET to api.opscode.com:443/organizations/xcentriq/nodes/training06.novalocal
DEBUG: ---- HTTP Status and Header Data: ----
DEBUG: HTTP 1.1 200 OK
DEBUG: server: nginx/1.0.5
DEBUG: date: Wed, 27 Feb 2013 09:31:00 GMT
DEBUG: content-type: application/json
DEBUG: transfer-encoding: chunked
DEBUG: connection: close
DEBUG: x-ops-api-info: flavor=ohc;version=10.0.0;oc_erchef=0.19.7
DEBUG: content-encoding: gzip
DEBUG: ---- End HTTP Status/Header Data ----
DEBUG: decompressing gzip response
/usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/lib/chef/knife/core/node_editor.rb:45:in view': undefined methodname' for #Hash:0x00000002ca6898 (NoMethodError)
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/lib/chef/knife/core/node_editor.rb:38:in edit_node' from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/lib/chef/knife/node_edit.rb:47:inrun'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/lib/chef/knife.rb:408:in run_with_pretty_exceptions' from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/lib/chef/knife.rb:168:inrun'
from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/lib/chef/application/knife.rb:123:in run' from /usr/local/rvm/gems/ruby-1.9.3-p374/gems/chef-10.18.2/bin/knife:25:in<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p374/bin/knife:19:in load' from /usr/local/rvm/gems/ruby-1.9.3-p374/bin/knife:19:in

'
from /usr/local/rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in eval' from /usr/local/rvm/gems/ruby-1.9.3-p374/bin/ruby_noexec_wrapper:14:in'

Role diffing breaks on certain characters

The diff functionality in role uploading is causing issues when certain characters are encountered in the role with errors like this:

sh: -c: line 4: syntax error near unexpected token `('

This is most likely an escaping issue with the text being passed to the diffy gem, and needs looking into.

knife-spork json file updates undo pretty print format

First and foremost, thanks for this life-changing tool. Sincerely: I'm a better Dad because of Knife-Spork! :-) The issue:

Basically, I have all json laid out in pretty-print format as it's much easier to manage, but anytime I run knife spork and it touches my json files, the pretty print formatting gets blown away. Possibly just a user issue on my part so sorry if I'm wasting your time. It has become quite a source of frustration in an otherwise peaceful knife-spork world.

Here's a link to a Gist that demonstrates the problem: https://gist.github.com/toddmichael/407b574e3b6662e0bbd2.

Appreciate the help. Cheers!

Issues with hipchat.rb?

Did a gem install of knife-spork via and my knife commands broke and ran into this

Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins/git.rb:69: warning: don't put space before argument parentheses
/Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins/git.rb:82: warning: don't put space before argument parentheses
/Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins/git.rb:95: warning: don't put space before argument parentheses
/Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins/git.rb:132: warning: don't put space before argument parentheses
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins/hipchat.rb:25: syntax error, unexpected tSYMBEG, expecting kDO or '{' or '(' (SyntaxError) ...message, notify:notify, color:color) ^ from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins.rb:4
from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins.rb:4:in each' from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/plugins.rb:4 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in require' from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/knife-spork/runner.rb:6 from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:ingem_original_require'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in require' from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.6/lib/chef/knife/spork-upload.rb:5 from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/knife/core/subcommand_loader.rb:37:inload'
from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/knife/core/subcommand_loader.rb:37:in load_commands' from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/knife/core/subcommand_loader.rb:37:ineach'
from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/knife/core/subcommand_loader.rb:37:in load_commands' from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/knife.rb:114:inload_commands'
from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/knife.rb:162:in run' from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/lib/chef/application/knife.rb:123:inrun'
from /Library/Ruby/Gems/1.8/gems/chef-10.14.2/bin/knife:25
from /usr/bin/knife:19:in `load'
from /usr/bin/knife:19

Any idea what's going on?

Thanks

Berkshelf integration (yes, again)

At Factlink we're in the process of moving our setup from a single chef-repo with librarian-chef towards a repo-per-cookbook with Berkshelf setup. During this move we're taking on bugs as they show up, as I did with knife-spork's Berkshelf integration, only to later find out that knife-spork might not be so suiting for Berkshelf integration at all.

First I will describe our current setup/folder structure:

~/dev/
    chef-repo/
    chef-factlink-web/
    chef-factlink-database/
    chef-factlink-otherstuff/

Originally we packed a Berksfile in our chef-repo in which we'd state all the direct dependencies:

cookbook 'chef-factlink-web'
cookbook 'chef-factlink-database'
cookbook 'chef-factlink-otherstuff'

This caused a lot of overhead in the update/upload process with Berkshelf, which made me do some investigating on a fluid Berkshelf flow. In berkshelf/berkshelf#535 @reset states that the chef-repo should NOT contain a Berksfile and that all application cookbooks should manage their own dependencies, which kinda makes sense to me, although it introduces a new problem with setting up knife-spork integration with Berkshelf.

In #74 @sethvargo introduced a way to resolve cookbooks through Berkshelf, but this doesn't work completely with the flow that is proposed in berkshelf/berkshelf#535 since I'm no longer able to promote chef-factlink-web directly, since there is no place to resolve this.

As stated we just started using Berkshelf, so maybe I'm missing something in this flow, so I am interested in learning what the correct knife-spork/berkshelf flow looks like.

If we're doing everything correctly, but something is indeed still missing in the knife-spork/berkshelf integration, I would like to propose support for running knife-spork from out of a cookbook folder itself, something along the likes of:

knife spork promote ENVIRONMENT .

What do you think?

"knife spork promote" with no args throws exception

Failure to specify a cookbook or environment throws an exception.

sm-nyc-jdunn:environments (master)$ knife spork promote -VV
/Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.2/lib/chef/cookbook_loader.rb:90:in `[]': undefined method `to_sym' for nil:NilClass (NoMethodError)
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.5/lib/knife-spork/runner.rb:104:in `load_cookbook'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.4/lib/chef/knife/spork-promote.rb:134:in `check_cookbook_uploaded'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.4/lib/chef/knife/spork-promote.rb:28:in `run'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.2/lib/chef/knife.rb:408:in `run_with_pretty_exceptions'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.2/lib/chef/knife.rb:168:in `run'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.2/lib/chef/application/knife.rb:123:in `run'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.2/bin/knife:25:in `<top (required)>'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/knife:19:in `load'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/knife:19:in `<main>'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
    from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'

Force option?

So in the case where we are doing test driven infrastructure there may be times someone might want to push a cookbook several times to run their tests. I wouldn't want to bump the version each time I want to test a new change especially in test driven infrastructure. At the end when I am satisfied with my changes I want all my changes to be part of one version number not several because there is a chance that several versions may be half baked. I could just by pass spork and do my own upload but I wonder if you thought about adding a force option?

Omni: Remotely promote by default via config setting

Have knife spork omni <cookbook> remotely promote by default, if configured to do so. Propose naming the config option 'yolo':

yolo: true

Except that phrase is tired and too contextual. You decide on the name, my good man.

Regression: Have to be in the root directory to "bump"

Previously you could be in any directory inside the git repo to perform Spork commands, but now if you're not in the root directory you get the following error:

[toolbox.ny4:~/chef-repo/cookbooks/hadoop/recipes (master)⚡] $ knife spork bump hadoop Pulling latest changes from remote Git repo. ERROR: You are not currently in a git repository. Ensure you are in the proper working directory or remove the git plugin from your KnifeSpork configuration!

Regression: Error handling for missing arguments on bump

[toolbox.ny4:~/chef-repo/cookbooks/hadoop/recipes (master)⚡] $ knife spork bump ERROR: knife encountered an unexpected error This may be a bug in the 'spork bump' knife command or plugin Please collect the output of this command with the -VVoption before filing a bug report. Exception: NoMethodError: undefined methodto_sym' for nil:NilClass`

Output using -VV:

DEBUG: Using configuration from /home/ldenness/.chef/knife.rb DEBUG: No chefignore file found at /home/ldenness/chef-repo/cookbooks/chefignore no files will be ignored WARN: found a directory etsystatus in the cookbook path, but it contains no cookbook files. skipping. /usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/cookbook_loader.rb:90:in []': undefined method to_sym' for nil:NilClass (NoMethodError) from /usr/lib64/ruby/gems/1.9.1/gems/knife-spork-1.0.2/lib/knife-spork/runner.rb:98:in load_cookbook'
from /usr/lib64/ruby/gems/1.9.1/gems/knife-spork-1.0.2/lib/chef/knife/spork-bump.rb:14:in run' from /usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/knife.rb:391:in run_with_pretty_exceptions'
from /usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/knife.rb:166:in run' from /usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.4/lib/chef/application/knife.rb:128:in run'
from /usr/lib64/ruby/gems/1.9.1/gems/chef-0.10.4/bin/knife:25:in <top (required)>' from /usr/bin/knife:19:in load'
from /usr/bin/knife:19:in <main>'

Feature Request: more details and accuracy in notifications

For those of us using multiple orgs to do prod/non-prod separation - it would be awesome, since we'd all have a clearer idea of which org the changes were taking place in.

so for example in current hip chat:

atrull uploaded and froze cookbook _mdsol_utilities version 0.0.33
atrull uploaded environment candidate
atrull uploaded and froze cookbook _mdsol_utilities version 0.0.33
atrull uploaded environment innovate
atrull uploaded environment production

what would be an improvement (and actually show what is going on):

mdsol-development : atrull uploaded and froze cookbook _mdsol_utilities version 0.0.33
mdsol-development : atrull uploaded environment candidate with cookbook _mdsol_utilities version 0.0.33
mdsol-production : atrull uploaded and froze cookbook _mdsol_utilities version 0.0.33
mdsol-production : atrull uploaded environment innovate with cookbook _mdsol_utilities version 0.0.33
mdsol-production : atrull uploaded environment production with cookbook _mdsol_utilities version 0.0.33

also, if the username were taken from the chef user instead of the local machine user, it would make significantly more sense.

Regards,

Alex Trull

git integration on windows gets stuck

I've got a developer trying to upload cookbooks from a windows/cygwin environment.

what is working:
knife cookbook upload works as expected - so knife itself is working OK.
a git pull indicates the repo os up to date.

what isn't:
knife spork bump or knife spork upload both get stuck on the git integration.

even with -VV it doesn't tell that much:

It prints: 'Pulling latest changes from git submodules (if any)' and gets no further.

I will ask the developer to to feed back directly on this issue himself.

knife spork promote with Berksfile

Hi folks,

I have a chef repo with a cookbooks folder, but empty.

A single environment named debug with nothing in there.

A Berksfile is present with:

cookbook 'zs-rabbitmq', git: '[email protected]:scalp42/zs-rabbitmq.git'

If I try to promote the cookbook zs-rabbitmq, it fails as expected (doesnt exist in the chef repo):

knife spork promote debug zs-rabbitmq

ERROR: Chef::Exceptions::CookbookNotFoundInRepo: Cannot find a cookbook named zs-rabbitmq; did you forget to add metadata to a cookbook? (http://wiki.opscode.com/display/chef/Metadata)

I saw that Berksfile option in the code, so if I try to use it and pass a Berksfile, it blows up:

knife spork promote debug zs-rabbitmq -b Berksfile -VV

/Users/scalp/.rvm/gems/ruby-1.9.3-p392@chef/gems/chef-11.4.4/lib/chef/cookbook_loader.rb:113:in `has_key?': undefined method `to_sym' for nil:NilClass (NoMethodError)
from /Users/scalp/.rvm/gems/ruby-1.9.3-p392@chef/gems/knife-spork-1.0.17/lib/knife-spork/runner.rb:106:in `load_cookbook'
from /Users/scalp/.chef/plugins/knife/spork-promote.rb:157:in `check_cookbook_uploaded'
from /Users/scalp/.chef/plugins/knife/spork-promote.rb:51:in `run'
from /Users/scalp/.rvm/gems/ruby-1.9.3-p392@chef/gems/chef-11.4.4/lib/chef/knife.rb:460:in `run_with_pretty_exceptions'
from /Users/scalp/.rvm/gems/ruby-1.9.3-p392@chef/gems/chef-11.4.4/lib/chef/knife.rb:173:in `run'
from /Users/scalp/.rvm/gems/ruby-1.9.3-p392@chef/gems/chef-11.4.4/lib/chef/application/knife.rb:123:in `run'
from /Users/scalp/.rvm/gems/ruby-1.9.3-p392@chef/gems/chef-11.4.4/bin/knife:25:in `<top (required)>'
from ./bin/knife:16:in `load'
from ./bin/knife:16:in `<main>'

I've tried multiple paths for the Berksfile, but it doesn't work.

Here is the list of my gems, if it helps:

berkshelf (1.4.5)
chef (11.4.4)
chef-rewind (0.0.5)
chefspec (1.2.0)
knife-ec2 (0.6.4)
knife-flip (0.1.6)
knife-preflight (0.1.6)
knife-server (1.0.1)
knife-spork (1.0.17)
minitest-chef-handler (1.0.1)

Any help would be greatly appreciated, thanks in advance.

Already initialized constants

Hi there,

I'm using knife-spork (1.0.17) and keep seeing these warnings:

/Users/scalp/.chef/plugins/knife/spork-bump.rb:8: warning: already initialized constant TYPE_INDEX
/Users/scalp/.chef/plugins/knife/spork-upload.rb:12: warning: already initialized constant CHECKSUM
/Users/scalp/.chef/plugins/knife/spork-upload.rb:13: warning: already initialized constant MATCH_CHECKSUM

It appears using knife data bag list for example (and pretty any data bag command).

Any help would be appreciated, thanks!

knife spork errors with Exception: NoMethodError: undefined method `[]' for :plugins:Symbol

Hi John and Anyone else paying attention.

My spork is broken:

Alexs-MacBook-Pro:chef-repo atrull$ knife spork bump zeromq
ERROR: knife encountered an unexpected error
This may be a bug in the 'spork bump' knife command or plugin
Please collect the output of this command with the -VV option before filing a bug report.
Exception: NoMethodError: undefined method `[]' for :plugins:Symbol

Alexs-MacBook-Pro:chef-repo atrull$ knife spork bump zeromq -VV
DEBUG: Using configuration from /Users/atrull/git/chef-repo/.chef/knife.rb
DEBUG: No chefignore file found at /Users/atrull/git/chef-repo/cookbooks/chefignore no files will be ignored
/Library/Ruby/Gems/1.8/gems/app_conf-0.4.0/lib/app_conf.rb:56:in method_missing': undefined method[]' for :plugins:Symbol (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/knife-spork/plugins/plugin.rb:40:in config' from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/knife-spork/plugins/plugin.rb:35:inenabled?'
from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/knife-spork/plugins.rb:11:in run' from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/knife-spork/plugins.rb:9:ineach'
from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/knife-spork/plugins.rb:9:in run' from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/knife-spork/runner.rb:32:inrun_plugins'
from /Library/Ruby/Gems/1.8/gems/knife-spork-1.0.12/lib/chef/knife/spork-bump.rb:24:in run' from /Library/Ruby/Gems/1.8/gems/chef-10.16.2/lib/chef/knife.rb:408:inrun_with_pretty_exceptions'
from /Library/Ruby/Gems/1.8/gems/chef-10.16.2/lib/chef/knife.rb:168:in run' from /Library/Ruby/Gems/1.8/gems/chef-10.16.2/lib/chef/application/knife.rb:123:inrun'
from /Library/Ruby/Gems/1.8/gems/chef-10.16.2/bin/knife:25
from /usr/bin/knife:19:in `load'
from /usr/bin/knife:19

I've used the documented spork-config, since I know the config format changed recently.

Here is the config hash:

Alexs-MacBook-Pro:chef-repo atrull$ knife spork info
Config Hash:
default_environmentsdevelopmentproductionpluginsjabberserver_port5222roomsengineering@your.conference.com/[email protected]/sporkserver_nameyour.jabberserver.comnicknameChef BotpasswordYOURPASSWORDusernameYOURUSERirccatchannelchef-annoucementsserverirccat.mydomain.comgist/usr/bin/gistport12345eventinatorurlhttp://eventinator.mydomain.com/events/oneshotgraphiteservergraphite.mydomain.comport2003hipchatroomsDevOps-Notificationsapi_tokend8445fd2dc36766f047a7colorrednotifytruegitenabledtruecampfireaccountmyaccounttokena1b2c3d4...environment_path/home/me/environmentsversion_change_threshold2

Plugins:
ERROR: knife encountered an unexpected error
This may be a bug in the 'spork info' knife command or plugin
Please collect the output of this command with the -VV option before filing a bug report.
Exception: NoMethodError: undefined method `[]' for :plugins:Symbol

Also FYI:

Alexs-MacBook-Pro:chef-repo atrull$ ruby --version
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

Thanks,

Alex

JSON format output

Hi,

It seems that knife-spork affects the pretty-print functionality. Since I installed this plugin, the node output went from a "clean" view of the
json to the json being "raw". It happens with a 'knife node edit' & 'knife node show'.

Here's an example, with knife-spork installed:

# knife node some.domain.tld -F json
{
  "some.domain.tld": {
    "run_list": [
      {"version":null,"type":"role","name":"base"},
      {"version":null,"type":"recipe","name":"openssl"},
      {"version":null,"type":"recipe","name":"mysql::server"},
      {"version":null,"type":"recipe","name":"confluence"}
    ]
  }
}

Then, once the gem is uninstalled:

# knife node show some.domain.tld -F json
{
  "some.domain.tld": {
    "run_list": [
      "role[base]",
      "recipe[openssl]",
      "recipe[mysql::server]",
      "recipe[confluence]"
    ]
  }
}

I'm currently using the latest release of knife-spork:

 # gem list|egrep 'chef|knife'
chef (11.4.4, 10.26.0)
knife-digital_ocean (0.1.1)
knife-solo (0.3.0)
knife-spork (1.2.1)
librarian-chef (0.0.1)

I wasn't able to pinpoint the problem by myself. Hope anyone can help!

Best regards.

spork check fails if the cookbook doesn't exist on the server

Hi,

I'm using knife spork in an automated fashion where we check the cookbook before pushing it with knife spork check and it seems to fail if the cookbook doesn't already exist. Is this by design? I may just have to check for the error code that it returns and continue if it returns "100" or would it be better to check the output returned instead? If there is an option to not return an error that would be great too.

Thanks,
Jay

Crash with new 1.2 release when no environment_groups in config file

Here's a crash that occurs when you don't have an environment_groups directive set to a Hash in your config/spork-config.yml file. This has been introduced in #75.

$ knife spork promote dev database -VV
DEBUG: Using configuration from /Users/kare/code/project/chef-repo/.chef/knife.rb
/Users/kare/.gem/ruby/1.9.3/gems/knife-spork-1.2.0/lib/knife-spork/runner.rb:56:in `load_specified_environment_group': undefined method `[]' for nil:NilClass (NoMethodError)
        from /Users/kare/.gem/ruby/1.9.3/gems/knife-spork-1.2.0/lib/knife-spork/runner.rb:48:in `load_environments_and_cookbook'
        from /Users/kare/.gem/ruby/1.9.3/gems/knife-spork-1.2.0/lib/chef/knife/spork-promote.rb:44:in `run'
        from /Users/kare/.gem/ruby/1.9.3/gems/chef-10.26.0/lib/chef/knife.rb:408:in `run_with_pretty_exceptions'
        from /Users/kare/.gem/ruby/1.9.3/gems/chef-10.26.0/lib/chef/knife.rb:168:in `run'
        from /Users/kare/.gem/ruby/1.9.3/gems/chef-10.26.0/lib/chef/application/knife.rb:123:in `run'
        from /Users/kare/.gem/ruby/1.9.3/gems/chef-10.26.0/bin/knife:25:in `<top (required)>'
        from /Users/kare/.gem/ruby/1.9.3/bin/knife:19:in `load'
        from /Users/kare/.gem/ruby/1.9.3/bin/knife:19:in `<main>'
        from /Users/kare/.gem/ruby/1.9.3/bin/ruby_noexec_wrapper:14:in `eval'
        from /Users/kare/.gem/ruby/1.9.3/bin/ruby_noexec_wrapper:14:in `<main>'

Version bump should use single-quoted strings

Using spork for bumping the version number will produce following error with rubocop:

metadata.rb:7:9: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
version "0.1.1"
        ^^^^^^^

Optional config param for where to find environments

It's not always safe to assume that environments live in an element of cookbook_path (stripping off /cookbooks of course) so we need a config parameter to let people point spork at a specific directory if the default isn't working.

promote version mismatch vs notifications

Hi All,

Just found a corker.

Looks like the notification is getting the version from the version on the filesystem, not the version specified in the command:

Alexs-MacBook-Pro:chef-repo atrull$ knife spork promote sandbox monit -v 0.1.23 --remote
Git: Pulling latest changes from /Users/atrull/git/chef-repo/.chef/../environments
Pulling latest changes from git submodules (if any)
Git: Pulling latest changes from /Users/atrull/git/chef-repo/cookbooks/monit
Pulling latest changes from git submodules (if any)
Adding version constraint monit = 0.1.23
Saving changes to sandbox.json
Uploading sandbox.json to Chef Server
Promotion complete at 2013-05-02 15:50:47 +0100!
Git add'ing /Users/atrull/git/chef-repo/.chef/../environments/sandbox.json

[15:50] KnifeSpork: mdsol: atrullmdsol promoted the following cookbooks: [email protected] to sandbox

Cheers,

Alex

Looks like a lot of WARNINGS are happening with ruby-2.x

13:40:46 [~/.chef] % knife spork info                                                                    
/Users/jasghar/.chef/plugins/knife/spork-bump.rb:8: warning: already initialized constant KnifeSpork::SporkBump::TYPE_INDEX
/Users/jasghar/.rvm/gems/ruby-2.0.0-p195/gems/knife-spork-1.2.2/lib/chef/knife/spork-bump.rb:8: warning: previous definition of TYPE_INDEX was here
/Users/jasghar/.chef/plugins/knife/spork-upload.rb:12: warning: already initialized constant KnifeSpork::SporkUpload::CHECKSUM
/Users/jasghar/.rvm/gems/ruby-2.0.0-p195/gems/knife-spork-1.2.2/lib/chef/knife/spork-upload.rb:12: warning: previous definition of CHECKSUM was here
/Users/jasghar/.chef/plugins/knife/spork-upload.rb:13: warning: already initialized constant KnifeSpork::SporkUpload::MATCH_CHECKSUM
/Users/jasghar/.rvm/gems/ruby-2.0.0-p195/gems/knife-spork-1.2.2/lib/chef/knife/spork-upload.rb:13: warning: previous definition of MATCH_CHECKSUM was here

I'm gonna see if i can fix this, but i think it should be at least documented here.

ArgumentError with Foodcritic 3.0.3

When running knife spork check with Foodcritc 3.0.3, I am getting the following error:

ERROR: ArgumentError: wrong number of arguments (2 for 1)

Downgrading to Foodcritic 2.2.0 resolved the problem.

I believe this is because the FoodCritic::Linter::new.check interface changed to include [cookbook_paths] in hash options.

.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/lib/chef/environment.rb:219:in `json_create': undefined method `[]' when doing promote

I get the following error:

sschueller@chef-workstation:~/chef-repo$ knife spork promote usability_wrapper -VV
/home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/lib/chef/environment.rb:219:in `json_create': undefined method `[]' for nil:NilClass (NoMethodError)
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/lib/chef/knife/core/object_loader.rb:92:in `object_from_file'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/knife-spork-1.2.1/lib/knife-spork/runner.rb:138:in `load_environment'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/knife-spork-1.2.1/lib/knife-spork/runner.rb:29:in `block in run_plugins'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/knife-spork-1.2.1/lib/knife-spork/runner.rb:29:in `collect'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/knife-spork-1.2.1/lib/knife-spork/runner.rb:29:in `run_plugins'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/knife-spork-1.2.1/lib/chef/knife/spork-promote.rb:46:in `run'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/lib/chef/knife.rb:466:in `run_with_pretty_exceptions'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/lib/chef/knife.rb:173:in `run'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/lib/chef/application/knife.rb:123:in `run'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/gems/chef-11.6.0/bin/knife:25:in `<top (required)>'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/bin/knife:19:in `load'
    from /home/sschueller/.rvm/gems/ruby-1.9.2-p320/bin/knife:19:in `<main>'

Hi have the following setup, however I had the same problem when installing ruby from apt:

Clean Ubuntu minimal install:

sudo apt-get install git -y
\curl -L https://get.rvm.io | bash -s stable
source /Users/sschueller/.rvm/scripts/rvm
rvm get stable
rvm install 1.9.2
rvm --default ruby-1.9.2 
gem install knife-spork knife-lastrun knife-flip
cd
git clone git://github.com/opscode/chef-repo.git

{configure chef and spork}

sschueller@chef-workstation:~/chef-repo$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.3 LTS
Release:    12.04
Codename:   precise
sschueller@chef-workstation:~/chef-repo$ ruby -v
ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-linux]
sschueller@chef-workstation:~/chef-repo$ gem list

*** LOCAL GEMS ***

app_conf (0.4.1)
chef (11.6.0)
colorize (0.5.8)
erubis (2.7.0)
git (1.2.6)
highline (1.6.19)
ipaddress (0.8.0)
json (1.7.7)
knife-flip (0.1.7)
knife-lastrun (0.0.4)
knife-spork (1.2.1)
mime-types (1.25)
mixlib-authentication (1.3.0)
mixlib-cli (1.3.0)
mixlib-config (1.1.2)
mixlib-log (1.6.0)
mixlib-shellout (1.2.0)
net-ssh (2.6.8)
net-ssh-gateway (1.2.0)
net-ssh-multi (1.1)
ohai (6.18.0)
rest-client (1.6.7)
rvm (1.11.3.8)
systemu (2.5.2)
yajl-ruby (1.1.0)

Any ideas what could be wrong?

Berkshelf Integration

Berkshelf and Knife both maintain different (and often conflicting) gem dependencies.
This isn't entirely surprising as Berkshelf is something of a knife replacement.

Given the above, I'm beginning to think that berkshelf integration in Knife-Spork is a unicorn.

spork stopped working with Chef 10.14.0

It looks like Chef 10.14.0 has removed the upload_cookbook method and replaced it with an upload_cookbooks (plural) method. This has broken Spork:

sm-nyc-jdunn:cookbooks (master)$ knife spork upload postgresql -VV
DEBUG: Using configuration from /Users/jdunn/.chef/knife.rb
DEBUG: No chefignore file found at /Users/jdunn/devel/git/chef/cookbooks/chefignore no files will be ignored
WARN: found a directory sonar in the cookbook path, but it contains no cookbook files. skipping.
/Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.2/lib/chef/knife/spork-upload.rb:65:in block in upload': undefined methodupload_cookbook' for #Chef::CookbookUploader:0x007ff78bb87290 (NoMethodError)
from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.2/lib/chef/knife/spork-upload.rb:62:in each' from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.2/lib/chef/knife/spork-upload.rb:62:inupload'
from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/knife-spork-1.0.2/lib/chef/knife/spork-upload.rb:47:in run' from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.0/lib/chef/knife.rb:408:inrun_with_pretty_exceptions'
from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.0/lib/chef/knife.rb:168:in run' from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.0/lib/chef/application/knife.rb:123:inrun'
from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/gems/chef-10.14.0/bin/knife:25:in <top (required)>' from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/knife:19:inload'
from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/knife:19:in <main>' from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:ineval'
from /Users/jdunn/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `

'

Update non-gem install docs

The current instructions for installing without using the gem do not work (require error for runner) and need updated.

spork bump failing for cookbook that exists

Hi,

It seems "knife spork bump" is failing for a cookbook that exists on our chef server. Any idea why this failure would happen? Anything you want me to diagnose?

Loaded config file /Users/jperry/workspace/bithub/chef/.chef/../config/spork-config.yml...

Opening git repo /Users/jperry/workspace//chef/

WARNING: Git: /Users/jperry/workspace//chef/cookbooks/ doesn't look like it's a git repo. Skipping git pull...

ERROR: Chef::Exceptions::CookbookNotFoundInRepo: Cannot find a cookbook named bithub; did you forget to add metadata to a cookbook? (http://wiki.opscode.com/display/chef/Metadata)

The cookbook is on the chef server as a show spits this out:

bithub   0.0.3  0.0.2  0.0.1

knife spork demote (or some way to remove cookbook versions from an environment)

Hi,

I've got a scenario where this would be useful functionality - particularly when combined with --remote.

In my organisation we have a cookbook development environment and a code development environment - both are expected to be on the latest cookbooks, but occasionally a developer will want to block changes reaching the code dev environment because the change breaks it, isolating the change to the cookbook dev environment.

Essentially the end of this process involves removing the version tag from the cod dev environment once the cookbook is stable enough - and this is something which spork could do 👍

What do you say ?

Reduces number of steps

I think the workflow has too many steps.
There should be fewer, or at least a shortcut.

Example:
How often do people upload and not bump + promote?
Some may while testing, but we could have the bump step do a promote. Multiple local promotes make no difference.

Also, we could drop the bump step completely. eg:
knife spork upload: Make this git pull + bump + promote + git commit + git push
Then you only have to knife spork promote --remote, reducing the workflow to just 2 steps.

Spork bump also runs git?

I noticed that when doing a "knife spork cookbook bump", it was also trying to do a "git add" of the cookbook. However, we don't use git -- would it be possible to easily configure spork to optionally understand svn instead, and have it automate that?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.