https://github.com/markolson/knife-node-attributes
A Knife plugin that outputs converged node attributes in JSON.
https://github.com/markolson/knife-node-attributes
Last synced: about 1 year ago
JSON representation
A Knife plugin that outputs converged node attributes in JSON.
- Host: GitHub
- URL: https://github.com/markolson/knife-node-attributes
- Owner: markolson
- License: mit
- Created: 2013-12-11T02:25:06.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-12-11T02:55:48.000Z (over 12 years ago)
- Last Synced: 2025-01-13T00:22:01.444Z (over 1 year ago)
- Language: Ruby
- Size: 105 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Knife::Node::Attributes
## Installation
Add this line to your application's Gemfile:
gem 'knife-node-attributes', git: 'http://github.com/lookingglass/knife-node-attributes'
and run `bundle install`
## Usage
When using Chef-Solo and Knife-Solo, you cannot fetch the node attributes from a last run.
Instead, this takes a crack at generating them ourselves based on what's in the run_list, environment, role,
and cookbooks..
Given `nodes/staging_web1.json` and a `environments/staging.{rb,json}`
{ "run_list":["role[webapp]"], "environment": "staging" }
You can run `knife node attributes -E staging -N web1 -j nodes/staging_web1.json` to get the attributes that the `Chef::Node` has before the recipes in the cookbooks are run. This means that if you're setting any attributes in the recipes themselves, they will not appear here.
Because the output is sent to STDOUT by default, you can pipe it into other scripts to process it more.
Given a script `versions.rb`:
#!/usr/bin/env ruby
require 'json'
JSON.parse($stdin.read).each {|k,v|
print %Q("#{k}", "#{v['version']}"\n) if v.is_a?(Hash) && v.has_key?('version')
}
You can get a CSV of the versions of everything (with a `version` attribute, at least) that may be on that node by
running `knife node attributes -E staging -N web1 -j nodes/staging_web1.json | ./versions.rb`
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request